コード例 #1
0
 /**
  * Reorder article
  *
  * @param	array	$article_ids
  * @return	boolean	true on success or false on fail
  */
 function reorder_article($article_ids)
 {
     if (!$this->check_token()) {
         return false;
     }
     if (!vivvo_hooks_manager::call('article_reorderArticle', array(&$article_ids))) {
         return vivvo_hooks_manager::get_status();
     }
     $sm = vivvo_lite_site::get_instance();
     if ($sm->user) {
         $editor_restriction = $sm->user->get_privilege_object_ids('EDITOR', 'Categories');
         if (!empty($editor_restriction)) {
             $article_list_ids = $article_ids;
             $article_list = new Articles_list();
             $article_list->search(array('search_id' => $article_ids), 'order_num', 'descending');
             $order_nums = $article_list->get_property_list('order_num');
             foreach ($article_list_ids as $k) {
                 $new_order = array_shift($order_nums);
                 $article_list->list[$k]->set_order_num($new_order);
                 $this->_post_master->set_data_object($article_list->list[$k]);
                 if (!$this->_post_master->sql_update()) {
                     $this->set_error_code(2019);
                     return false;
                 }
             }
             admin_log($sm->user->get_username(), 'Reordered articles #' . trim(implode(',', $article_list_ids)));
             return true;
         } else {
             $this->set_error_code(2020);
             return false;
         }
     } else {
         $this->set_error_code(2021);
         return false;
     }
 }