Changeset 12462

Show
Ignore:
Timestamp:
09/25/07 11:34:33 (1 year ago)
Author:
bergie
Message:

Fix uploading to gallery and bulletproof gallery in case of deleted photos, refs #127

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/midcom/midcom.helper.datamanager2/widget/chooser.php

    r12460 r12462  
    624624                    array('metadata.published' => 'ASC'), 
    625625                ), 
    626                 'id_field' => 'guid', 
    627626            ), 
    628627        ); 
     
    10231022        // Add existing and static selections 
    10241023        $existing_elements = $this->_type->selection; 
     1024         
    10251025        // debug_print_r('existing_elements',$existing_elements); 
    10261026 
    10271027        // debug_print_r('static_options',$this->static_options); 
    10281028         
    1029         $elements = array_merge($this->static_options,$existing_elements); 
     1029        $elements = array_merge($this->static_options, $existing_elements); 
    10301030        // debug_print_r('all elements to be added',$elements); 
    10311031                 
     
    12971297        } 
    12981298        $real_results =& $results["{$this->_element_id}_selections"]; 
    1299          
    1300         foreach ($real_results as $key => $value) 
    1301         { 
    1302             // debug_add("checking key {$key} with value ".var_dump($value)); 
    1303             if (   $value != "0" 
    1304                 || $value != 0) 
    1305             { 
    1306                 // debug_add("adding key {$key} to selection"); 
    1307                 $this->_type->selection[] = $key;                 
     1299        if (is_array($real_results)) 
     1300        { 
     1301            foreach ($real_results as $key => $value) 
     1302            { 
     1303                // debug_add("checking key {$key} with value ".var_dump($value)); 
     1304                if (   $value != "0" 
     1305                    || $value != 0) 
     1306                { 
     1307                    // debug_add("adding key {$key} to selection"); 
     1308                    $this->_type->selection[] = $key;                 
     1309                } 
    13081310            } 
    13091311        } 
  • trunk/midcom/org.routamc.gallery/handler/index.php

    r11649 r12462  
    126126        foreach ($photolinks as $photolink) 
    127127        { 
     128 
    128129            $photo = new org_routamc_photostream_photo_dba($photolink->photo); 
    129             if (!$photo) 
     130            if (   !$photo 
     131                || !$photo->guid) 
    130132            { 
    131133                debug_add("Could not read photo #{$photolink->photo}, errstr: " . mgd_errstr(), MIDCOM_LOG_WARN); 
  • trunk/midcom/org.routamc.gallery/viewer.php

    r11646 r12462  
    8484            $nap = new midcom_helper_nav(); 
    8585            $photostream_node = $nap->get_node($photostream->id); 
     86             
    8687            return $photostream_node; 
    8788        } 
    88  
     89         
    8990        // No photostream specified, autoprobe 
    9091        $photostream_node = midcom_helper_find_node_by_component('org.routamc.photostream'); 
    9192 
    9293        // Cache the data 
    93         // TODO: sudo here? 
    94         $this->_topic->parameter('org.routamc.gallery', 'photostream', $photostream_node[MIDCOM_NAV_GUID]); 
     94        if ($_MIDCOM->auth->request_sudo('org.routamc.gallery')) 
     95        { 
     96            $this->_topic->parameter('org.routamc.gallery', 'photostream', $photostream_node[MIDCOM_NAV_GUID]); 
     97            $_MIDCOM->auth->drop_sudo(); 
     98        } 
    9599 
    96100        return $photostream_node; 
     
    108112            array 
    109113            ( 
    110                 MIDCOM_TOOLBAR_URL => "{$this->_request_data['photostream'][MIDCOM_NAV_FULLURL]}upload.html", 
     114                MIDCOM_TOOLBAR_URL => "{$this->_request_data['photostream'][MIDCOM_NAV_FULLURL]}upload.html?to_gallery={$this->_topic->id}", 
    111115                MIDCOM_TOOLBAR_LABEL => $_MIDCOM->i18n->get_string('upload photos', 'org.routamc.photostream'), 
    112116                MIDCOM_TOOLBAR_HELPTEXT => null, 
  • trunk/midcom/org.routamc.photostream/config/schemadb_default.inc

    r5954 r12462  
    2929                 'options' => array(), 
    3030            ), 
    31             'widget' => 'universalchooser', 
     31            'widget' => 'chooser', 
    3232            'widget_config' => array 
    3333            ( 
    34                 'class'       => 'midcom_db_person', 
    35                 'component'   => 'org.openpsa.contacts', 
    36                 'titlefield'  => 'name', 
    37                 'idfield'     => 'id', 
    38                 'constraints' => array 
    39                 ( 
    40                 ), 
    41                 'searchfields'  => array 
    42                 ( 
    43                     'lastname', 
    44                     'firstname', 
    45                     'username' 
    46                 ), 
    47                 'orders'        => array 
    48                 ( 
    49                     array('lastname'   => 'ASC'), 
    50                     array('firstname'  => 'ASC'), 
    51                 ), 
     34                'clever_class' => 'person', 
     35                'id_field' => 'id', 
    5236            ), 
    5337        ), 
     
    152136            'index_method' => 'title', 
    153137        ), 
    154         'description' => Array 
    155         ( 
    156             'title' => 'description', 
    157             'storage' => 'description', 
    158             'type' => 'text', 
    159             'widget' => 'textarea', 
    160         ), 
    161         'photographer' => array 
    162         ( 
    163             'title' => 'photographer', 
    164             'storage' => 'photographer', 
    165             'type' => 'select', 
    166             'type_config' => array 
    167             ( 
    168                  'require_corresponding_option' => false, 
    169                  'options' => array(), 
    170             ), 
    171             'widget' => 'universalchooser', 
    172             'widget_config' => array 
    173             ( 
    174                 'class'       => 'midcom_db_person', 
    175                 'component'   => 'org.openpsa.contacts', 
    176                 'titlefield'  => 'name', 
    177                 'idfield'     => 'id', 
    178                 'constraints' => array 
    179                 ( 
    180                 ), 
    181                 'searchfields'  => array 
    182                 ( 
    183                     'lastname', 
    184                     'firstname', 
    185                     'username' 
    186                 ), 
    187                 'orders'        => array 
    188                 ( 
    189                     array('lastname'    => 'ASC'), 
    190                     array('firstname'  => 'ASC'), 
    191                 ), 
    192             ), 
    193             'required' => true, 
    194         ), 
    195         'tags' => Array 
    196         ( 
    197             'title' => 'tags', 
    198             'type' => 'tags', 
    199             'widget' => 'text', 
    200         ), 
    201138        /* NOTE: You *will* want to migrate all changes made here to the same 
    202139          field in the photo schema as well */ 
     
    217154            'widget' => 'photo', 
    218155        ), 
    219         'private' => Array 
    220         ( 
    221             'title' => 'private', 
    222             'description' => 'if checked only you can see this photo', 
    223             'storage' => null, 
    224             'type' => 'privilegeset', 
    225             'type_config' => Array 
    226             ( 
    227                 'privileges' => Array 
    228                 ( 
    229                     Array('midgard:read', 'EVERYONE', MIDCOM_PRIVILEGE_DENY), 
    230                 ), 
    231             ), 
    232             'widget' => 'privilegecheckbox', 
    233         ), 
    234         'not_public' => Array 
    235         ( 
    236             'title' => 'not public', 
    237             'description' => 'if checked only logged in users can see this photo', 
    238             'storage' => null, 
    239             'type' => 'privilegeset', 
    240             'type_config' => Array 
    241             ( 
    242                 'privileges' => Array 
    243                 ( 
    244                     Array('midgard:read', 'ANONYMOUS', MIDCOM_PRIVILEGE_DENY), 
    245                 ), 
    246             ), 
    247             'widget' => 'privilegecheckbox', 
    248         ), 
    249         'to_gallery' => array 
    250         ( 
    251             'title' => 'upload to gallery', 
    252             'storage' => null, 
     156        'description' => Array 
     157        ( 
     158            'title' => 'description', 
     159            'storage' => 'description', 
     160            'type' => 'text', 
     161            'widget' => 'textarea', 
     162        ), 
     163        'tags' => Array 
     164        ( 
     165            'title' => 'tags', 
     166            'type' => 'tags', 
     167            'widget' => 'text', 
     168        ),   
     169        'photographer' => array 
     170        ( 
     171            'title' => 'photographer', 
     172            'storage' => 'photographer', 
    253173            'type' => 'select', 
    254174            'type_config' => array 
     
    257177                 'options' => array(), 
    258178            ), 
    259             'widget' => 'universalchooser', 
     179            'widget' => 'chooser', 
    260180            'widget_config' => array 
    261181            ( 
    262                 'class'       => 'midcom_db_topic', 
    263                 'component'   => 'org.routamc.photostream', 
    264                 'titlefield'  => 'extra', 
    265                 'idfield'     => 'id', 
     182                'clever_class' => 'person', 
     183                'id_field' => 'id', 
     184            ), 
     185            'required' => true, 
     186        ), 
     187        'to_gallery' => array 
     188        ( 
     189            'title' => 'upload to gallery', 
     190            'storage' => 'parameter', 
     191            'type' => 'select', 
     192            'type_config' => array 
     193            ( 
     194                 'require_corresponding_option' => false, 
     195                 'options' => array(), 
     196            ), 
     197            'widget' => 'chooser', 
     198            'widget_config' => array 
     199            ( 
     200                'clever_class' => 'topic', 
     201                'id_field' => 'id', 
    266202                'constraints' => array 
    267203                ( 
    268204                    array 
    269205                    ( 
    270                         'field' => 'parameter.domain', 
     206                        'field' => 'component', 
    271207                        'op' => '=', 
    272208                        'value' => 'org.routamc.gallery', 
     
    285221                    ), 
    286222                ), 
    287                 'searchfields'  => array 
    288                 ( 
    289                     'name', 
    290                     'extra', 
    291                 ), 
    292                 'orders'        => array 
    293                 ( 
    294                     array('extra'    => 'ASC'), 
    295                     array('name'  => 'ASC'), 
    296                 ), 
    297             ), 
     223            ), 
     224        ), 
     225        'private' => Array 
     226        ( 
     227            'title' => 'private', 
     228            'description' => 'if checked only you can see this photo', 
     229            'storage' => null, 
     230            'type' => 'privilegeset', 
     231            'type_config' => Array 
     232            ( 
     233                'privileges' => Array 
     234                ( 
     235                    Array('midgard:read', 'EVERYONE', MIDCOM_PRIVILEGE_DENY), 
     236                ), 
     237            ), 
     238            'widget' => 'privilegecheckbox', 
     239        ), 
     240        'not_public' => Array 
     241        ( 
     242            'title' => 'not public', 
     243            'description' => 'if checked only logged in users can see this photo', 
     244            'storage' => null, 
     245            'type' => 'privilegeset', 
     246            'type_config' => Array 
     247            ( 
     248                'privileges' => Array 
     249                ( 
     250                    Array('midgard:read', 'ANONYMOUS', MIDCOM_PRIVILEGE_DENY), 
     251                ), 
     252            ), 
     253            'widget' => 'privilegecheckbox', 
    298254        ), 
    299255    ) 
  • trunk/midcom/org.routamc.photostream/handler/upload.php

    r6029 r12462  
    8080            $user = $_MIDCOM->auth->user->get_storage(); 
    8181            $this->_defaults['photographer'] = $user->id; 
     82        } 
     83         
     84        if (isset($_REQUEST['to_gallery'])) 
     85        { 
     86            $this->_defaults['to_gallery'] = $_REQUEST['to_gallery']; 
    8287        } 
    8388    } 
     
    355360        debug_push_class(__CLASS__, __FUNCTION__); 
    356361        debug_add('Called'); 
    357         /* This seems not to work, let's try a more raw approach 
    358         if (!isset($this->_controller->datamanager->types['to_gallery'])) 
    359         { 
    360             debug_add('Could not find to_gallery-field in schema'); 
    361             debug_pop(); 
    362             return; 
    363         } 
    364         debug_print_r('to_gallery: ', $this->_controller->datamanager->types['to_gallery']); 
    365         $gallery =& $this->_controller->datamanager->types['to_gallery']->value; 
    366         */ 
    367         if (!isset($_POST['to_gallery'])) 
     362 
     363        if (!isset($_POST['org_routamc_photostream_to_gallery_chooser_widget_selections'])) 
    368364        { 
    369365            debug_add('Could not find to_gallery-field in POST'); 
     
    371367            return; 
    372368        } 
    373         $gallery =& $_POST['to_gallery']; 
     369 
     370        $gallery = (int) $_POST['org_routamc_photostream_to_gallery_chooser_widget_selections']; 
    374371        if (empty($gallery)) 
    375372        { 
     
    396393        debug_add("Photo #{$this->_photo->id} linked to gallery #{$gallery}", MIDCOM_LOG_INFO); 
    397394        debug_pop(); 
     395 
    398396        return; 
    399397    } 
     
    426424        { 
    427425            case 'save': 
    428                 // Change schema on the fly ffrom upload to photo 
     426                // Change schema on the fly from 'upload' to 'photo' 
    429427                $this->_photo->parameter('midcom.helper.datamanager2', 'schema_name', 'photo'); 
    430428                $this->_photo->read_exif_data(true);