Changeset 1939

Show
Ignore:
Timestamp:
2006-02-02 15:17:18 (3 years ago)
Author:
ctford
Message:

Allow basic updating of clips.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • Anode/trunk/acidfree/class_annodex.inc

    r1936 r1939  
    164164                $editing = TRUE; 
    165165        }  
     166        if( $editing && $_POST['id'] ) { 
     167                insert_clip( $_POST, $node );    
     168        } 
     169 
    166170 
    167171        $arg_name = "media"; 
     
    194198        } else { 
    195199 
    196                 if( $editing && $_POST['id'] ) { 
    197                         insert_clip( $_POST );   
    198                 } 
    199  
    200200                $output .= "<h1>"; 
    201201                $output .= l("Annodex", "node/{$node->nid}",NULL,"$arg_name=annodex")." "; 
     
    208208 
    209209                while( $row = db_fetch_object($result) ) { 
     210                        if( $row->img ) { 
     211                                $output .= "<a href = \"node/{$node->nid}&id={$row->id}><img src=\"{$row->img}></a>"; 
     212                        } 
    210213                        $output .= l($row->id, "node/{$node->nid}",NULL,"$arg_name=annodex&id={$row->id}")."<br />"; 
    211214                } 
     
    228231                } 
    229232                 
    230  
    231233                $output .= $node->body; 
    232234        } 
     
    236238 
    237239/* FIXME Need major error checking. */ 
    238 function insert_clip( $attributes ) { 
     240function insert_clip( $attributes, $node ) { 
    239241        if( $attributes['id'] ) { 
    240242                $start = 60*60*$attributes['start_hours'] + 60*$attributes['start_minutes'] + $attributes['start_seconds']; 
    241                 $result = db_query("INSERT INTO {acidfree_cmml_clips} (`nid`, `a_href`, `a_text`, `img`, `desc`, `start`, `end`, `id`, `track`) VALUES('{$node->nid}', '{$attributes['a_href']}', '{$attributes['a_text']}', '{$attributes['img']}', '{$attributes['desc']}', '$start', '{$attributes['end']}','{$attributes['id']}', '{$attributes['track']}');");              
     243 
     244                /* Check whether we need to create a new clip or just update an 
     245                 * old one. 
     246                 */ 
     247                $occurances = db_result(db_query("SELECT COUNT(`id`) FROM {acidfree_cmml_clips} WHERE `id` = '{$attributes['id']}';")); 
     248 
     249                if( $occurances == 0 ) { 
     250                        $result = db_query("INSERT INTO {acidfree_cmml_clips} (`nid`, `a_href`, `a_text`, `img`, `desc`, `start`, `end`, `id`, `track`) VALUES('{$node->nid}', '{$attributes['a_href']}', '{$attributes['a_text']}', '{$attributes['img']}', '{$attributes['desc']}', '$start', '{$attributes['end']}','{$attributes['id']}', '{$attributes['track']}');");              
     251                } else { 
     252                        $result = db_query("UPDATE {acidfree_cmml_clips} SET `nid` = '{$node->nid}', `a_href` = '{$attributes['a_href']}', `a_text` = '{$attributes['a_text']}', `img` = '{$attributes['img']}', `desc` = '{$attributes['desc']}', `start` = '$start', `end` = '{$attributes['end']}', `id` = '{$attributes['id']}', `track` = '{$attributes['track']}' WHERE `id` = '{$attributes['id']}';"); 
     253                } 
    242254        } 
    243255        return;