Exemplo n.º 1
0
 public function update()
 {
     global $DB;
     global $website;
     global $events;
     global $user;
     if (!is_null($user)) {
         if ($user->permission("items.edit") == 'false' && $this->author != $user->id) {
             throw new Exception(t(610, "Sorry, you are not allowed to execute this function."));
         }
         if (!structure::category_allowed($this->category)) {
             throw new Exception(t(610, "Sorry, you are not allowed to execute this function."));
         }
     }
     $this->date_modified = core_time();
     $groups = '';
     if (is_array($this->groups)) {
         $this->groups = array_unique($this->groups);
         // remove duplicates
         $this->groups = array_filter($this->groups);
         // remove empty
         if (!empty($this->groups)) {
             $groups = 'g' . implode(',g', $this->groups);
         }
     }
     if ($groups == 'g') {
         $groups = '';
     }
     $ok = $DB->execute(' 
         UPDATE nv_items
         SET 
             association	= :association,
             category	=   :category,
             embedding	= 	:embedding,
             template	=   :template,
             date_to_display	=  :date_to_display,
             date_published	=  :date_published,
             date_unpublish	=  :date_unpublish,
             date_modified	=  :date_modified,
             author		=   :author,
             galleries	=  :galleries,
             comments_enabled_to = :comments_enabled_to,
             comments_moderator = :comments_moderator,
             access	 	=  :access,
             groups      =  :groups,
             permission 	=  :permission,
             views 	=  :views,
             votes 	=  :votes,
             score 	=  :score,
             position = :position
         WHERE id = :id
           AND website = :website', array(":association" => $this->association, ":category" => $this->category, ":embedding" => $this->embedding, ":template" => $this->template, ":date_to_display" => value_or_default($this->date_to_display, 0), ":date_published" => value_or_default($this->date_published, 0), ":date_unpublish" => value_or_default($this->date_unpublish, 0), ":date_modified" => $this->date_modified, ":author" => $this->author, ":galleries" => serialize($this->galleries), ":comments_enabled_to" => value_or_default($this->comments_enabled_to, 0), ":comments_moderator" => value_or_default($this->comments_moderator, 0), ":access" => $this->access, ":groups" => $groups, ":permission" => $this->permission, ":views" => $this->views, ":votes" => $this->votes, ":score" => $this->score, ":position" => value_or_default($this->position, 0), ":id" => $this->id, ":website" => $this->website));
     if (!$ok) {
         throw new Exception($DB->get_last_error());
     }
     webdictionary::save_element_strings('item', $this->id, $this->dictionary, $this->website);
     webdictionary_history::save_element_strings('item', $this->id, $this->dictionary, false, $this->website);
     path::saveElementPaths('item', $this->id, $this->paths, $this->website);
     $events->trigger('item', 'save', array('item' => $this));
     return true;
 }
Exemplo n.º 2
0
 public static function remove_properties($element_type, $element_id)
 {
     global $DB;
     global $website;
     webdictionary::save_element_strings('property-' . $element_type, $element_id, array());
     $DB->execute('
         DELETE FROM nv_properties_items
               WHERE website = ' . $website->id . '
                 AND element = ' . protect($element_type) . '
                 AND node_id = ' . intval($element_id) . '
     ');
 }
Exemplo n.º 3
0
    public function update()
    {
        global $DB;
        global $website;
        $groups = '';
        if (is_array($this->groups)) {
            $this->groups = array_unique($this->groups);
            // remove duplicates
            $this->groups = array_filter($this->groups);
            // remove empty
            if (!empty($this->groups)) {
                $groups = 'g' . implode(',g', $this->groups);
            }
        }
        if ($groups == 'g') {
            $groups = '';
        }
        $ok = $DB->execute('
 			UPDATE nv_structure
			   SET  parent = :parent, position = :position, access = :access, groups = :groups,
			   		permission = :permission, icon = :icon, metatags = :metatags,
					date_published = :date_published, date_unpublish = :date_unpublish,
					template = :template, visible = :visible, views = :views, votes = :votes, score = :score
			 WHERE id = :id
			   AND website = :website
		   ', array(":id" => $this->id, ":website" => $this->website, ":parent" => value_or_default($this->parent, 0), ":position" => $this->position, ":access" => $this->access, ":groups" => $groups, ":permission" => $this->permission, ":icon" => value_or_default($this->icon, ''), ":metatags" => value_or_default($this->metatags, ''), ":template" => $this->template, ":date_published" => value_or_default($this->date_published, 0), ":date_unpublish" => value_or_default($this->date_unpublish, 0), ":visible" => $this->visible, ":views" => $this->views, ":votes" => $this->votes, ":score" => $this->score));
        if (!$ok) {
            throw new Exception($DB->get_last_error());
        }
        webdictionary::save_element_strings('structure', $this->id, $this->dictionary, $this->website);
        path::saveElementPaths('structure', $this->id, $this->paths, $this->website);
        return true;
    }
Exemplo n.º 4
0
 public function update()
 {
     global $DB;
     global $user;
     if (!is_array($this->categories)) {
         $this->categories = array();
     }
     if (!is_array($this->exclusions)) {
         $this->exclusions = array();
     }
     if (!empty($user->id)) {
         if ($user->permission("blocks.edit") == 'false') {
             throw new Exception(t(610, "Sorry, you are not allowed to execute this function."));
         }
     }
     $groups = '';
     if (is_array($this->groups)) {
         $this->groups = array_unique($this->groups);
         // remove duplicates
         $this->groups = array_filter($this->groups);
         // remove empty
         if (!empty($this->groups)) {
             $groups = 'g' . implode(',g', $this->groups);
         }
     }
     if ($groups == 'g') {
         $groups = '';
     }
     $ok = $DB->execute('UPDATE nv_blocks
          SET
             `type`			= :type,
             date_published 	= :date_published,
             date_unpublish  = :date_unpublish,
             `position` 		= :position,
             fixed	        = :fixed,
             categories		= :categories,
             exclusions		= :exclusions,
             elements        = :elements,
             `trigger` 		= :trigger,
             `action` 		= :action,
             access 			= :access,
             groups          = :groups,
             enabled 		= :enabled,
             notes	 		= :notes,
             date_modified	= :date_modified
          WHERE id = :id
            AND website = :website
         ', array(':id' => $this->id, ':website' => $this->website, ':type' => $this->type, ':date_published' => value_or_default($this->date_published, 0), ':date_unpublish' => value_or_default($this->date_unpublish, 0), ':position' => value_or_default($this->position, 0), ':fixed' => value_or_default($this->fixed, 0), ':categories' => implode(',', $this->categories), ':exclusions' => implode(',', $this->exclusions), ':elements' => json_encode($this->elements), ':access' => value_or_default($this->access, 0), ':groups' => $groups, ':enabled' => value_or_default($this->enabled, 0), ':trigger' => serialize($this->trigger), ':action' => serialize($this->action), ':notes' => value_or_default($this->notes, ""), ':date_modified' => time()));
     if (!$ok) {
         throw new Exception($DB->get_last_error());
     }
     webdictionary::save_element_strings('block', $this->id, $this->dictionary, $this->website);
     return true;
 }
Exemplo n.º 5
0
    public function update()
    {
        global $DB;
        if (!is_array($this->categories)) {
            $this->categories = array();
        }
        $ok = $DB->execute(' 
 			UPDATE nv_feeds
			  SET categories = :categories, format = :format, image = :image, entries = :entries, 
			  	  content = :content, views = :views, permission = :permission, enabled = :enabled
			WHERE id = :id	AND	website = :website', array('id' => $this->id, 'website' => $this->website, 'categories' => implode(',', $this->categories), 'format' => $this->format, 'image' => value_or_default($this->image, 0), 'entries' => value_or_default($this->entries, 10), 'content' => $this->content, 'views' => value_or_default($this->views, 0), 'permission' => value_or_default($this->permission, 0), 'enabled' => value_or_default($this->enabled, 0)));
        if (!$ok) {
            throw new Exception($DB->get_last_error());
        }
        webdictionary::save_element_strings('feed', $this->id, $this->dictionary);
        path::saveElementPaths('feed', $this->id, $this->paths);
        return true;
    }