コード例 #1
0
 /**
  * This function will return paginated result. Result is an array where first element is 
  * array of returned object and second populated pagination object that can be used for 
  * obtaining and rendering pagination data using various helpers.
  * 
  * Items and pagination array vars are indexed with 0 for items and 1 for pagination
  * because you can't use associative indexing with list() construct
  *
  * @access public
  * @param array $arguments Query argumens (@see find()) Limit and offset are ignored!
  * @param integer $items_per_page Number of items per page
  * @param integer $current_page Current page number
  * @return array
  */
 function paginate($arguments = null, $items_per_page = 10, $current_page = 1)
 {
     if (isset($this) && instance_of($this, 'Comments')) {
         return parent::paginate($arguments, $items_per_page, $current_page);
     } else {
         return Comments::instance()->paginate($arguments, $items_per_page, $current_page);
         //$instance =& Comments::instance();
         //return $instance->paginate($arguments, $items_per_page, $current_page);
     }
     // if
 }
コード例 #2
0
 /**
  *  Returns al objects that will be found on the dashboard.
  *    Functions used only in ObjectController
  *
  * @param int $page
  * @param int $objects_per_page
  * @param string $order
  * @param string $order_dir can be asc or desc
  */
 function getDashboardObjects($page, $objects_per_page, $tag = null, $order = null, $order_dir = null, $types = null, $project = null, $trashed = false, $linkedObject = null, $filterName = "", $archived = false, $filterManager = '')
 {
     ///TODO: this method is horrible on performance and should not be here!!!!
     $queries = $this->getDashboardObjectQueries($project, $tag, false, $trashed, $linkedObject, $order, $filterName, $archived, $filterManager);
     if (!$order_dir) {
         switch ($order) {
             case 'name':
                 $order_dir = 'ASC';
                 break;
             default:
                 $order_dir = 'DESC';
         }
     }
     if (isset($types) && $types) {
         $query = '';
         foreach ($types as $type) {
             if ($query == '') {
                 $query = $queries[$type];
             } else {
                 $query .= " \n UNION \n" . $queries[$type];
             }
         }
     } else {
         $query = '';
         foreach ($queries as $q) {
             if ($query == '') {
                 $query = $q;
             } else {
                 $query .= " \n UNION \n" . $q;
             }
         }
     }
     if ($order) {
         $query .= " ORDER BY `order_value` ";
         if ($order_dir) {
             $query .= " " . mysql_real_escape_string($order_dir) . " ";
         }
     } else {
         $query .= " ORDER BY `order_value` DESC ";
     }
     if ($page && $objects_per_page) {
         $start = ($page - 1) * $objects_per_page;
         $query .= " LIMIT " . $start . "," . $objects_per_page . " ";
     } elseif ($objects_per_page) {
         $query .= " LIMIT " . $objects_per_page;
     }
     $res = DB::execute($query);
     $objects = array();
     if (!$res) {
         return $objects;
     }
     $rows = $res->fetchAll();
     if (!$rows) {
         return $objects;
     }
     $index = 0;
     foreach ($rows as $row) {
         $manager = $row['object_manager_value'];
         $id = $row['oid'];
         if ($id && $manager) {
             $obj = get_object_by_manager_and_id($id, $manager);
             if ($obj->canView(logged_user())) {
                 $objects[] = $obj;
             }
         }
         //if($id && $manager)
     }
     //foreach
     ProjectDataObjects::populateData($objects);
     $dash_objects = array();
     foreach ($objects as $obj) {
         //Logger::log('DASH');
         $dash_object = $obj->getDashboardObject();
         $dash_object['ix'] = $index++;
         $dash_objects[] = $dash_object;
     }
     return $dash_objects;
 }
コード例 #3
0
 /**
 * This function will return paginated result. Result is an array where first element is 
 * array of returned object and second populated pagination object that can be used for 
 * obtaining and rendering pagination data using various helpers.
 * 
 * Items and pagination array vars are indexed with 0 for items and 1 for pagination
 * because you can't use associative indexing with list() construct
 *
 * @access public
 * @param array $arguments Query argumens (@see find()) Limit and offset are ignored!
 * @param integer $items_per_page Number of items per page
 * @param integer $current_page Current page number
 * @return array
 */
 function paginate($arguments = null, $items_per_page = 10, $current_page = 1) {
   if(isset($this) && instance_of($this, 'ProjectCharts')) {
     return parent::paginate($arguments, $items_per_page, $current_page);
   } else {
     return ProjectCharts::instance()->paginate($arguments, $items_per_page, $current_page);
   } // if
 } // paginate
コード例 #4
0
 /**
  * Lists all contacts and clients
  *
  */
 function list_all()
 {
     ajx_current("empty");
     // Get all variables from request
     $start = array_var($_GET, 'start', 0);
     $limit = array_var($_GET, 'limit', config_option('files_per_page'));
     $page = 1;
     if ($start > 0) {
         $page = $start / $limit + 1;
     }
     $order = array_var($_GET, 'sort');
     $order_dir = array_var($_GET, 'dir');
     $tag = array_var($_GET, 'tag');
     $action = array_var($_GET, 'action');
     $attributes = array("ids" => explode(',', array_var($_GET, 'ids')), "types" => explode(',', array_var($_GET, 'types')), "tag" => array_var($_GET, 'tagTag'), "accountId" => array_var($_GET, 'account_id'), "viewType" => array_var($_GET, 'view_type'), "moveTo" => array_var($_GET, 'moveTo'), "mantainWs" => array_var($_GET, 'mantainWs'), "tagTag" => array_var($_GET, 'tagTag'));
     //Resolve actions to perform
     $actionMessage = array();
     if (isset($action)) {
         $actionMessage = $this->resolveAction($action, $attributes);
         if ($actionMessage["errorCode"] == 0) {
             flash_success($actionMessage["errorMessage"]);
         } else {
             flash_error($actionMessage["errorMessage"]);
         }
     }
     // Get all emails and companies to contacts
     $project = active_project();
     /*$contacts = $this->getContacts($tag, $attributes, $project);
     		$companies = array();
     		$companies = $this->getCompanies($tag, $attributes, $project);
     		$union = $this->addContactsAndCompanies($contacts, $companies);*/
     $type = null;
     if ($attributes['viewType'] == 'contacts') {
         $type = 'Contacts';
     } else {
         if ($attributes['viewType'] == 'companies') {
             $type = 'Companies';
         }
     }
     $count = $this->countContactObjects($tag, $type, $project);
     if ($start > $count) {
         $start = 0;
         $page = 1;
     }
     if ($count > 0) {
         $union = $this->getContactObjects($page, $limit, $tag, $order, $order_dir, $type, $project);
     } else {
         $union = array();
     }
     ProjectDataObjects::populateData($union);
     // Prepare response object
     $object = $this->newPrepareObject($union, $count, $start, $attributes);
     ajx_extra_data($object);
     tpl_assign("listing", $object);
 }