コード例 #1
0
 function ExecuteQuery()
 {
     $this->data = array();
     $queries = ObjectController::getDashboardObjectQueries(active_project(), null, true);
     $query = '';
     foreach ($queries as $k => $q) {
         if (substr($k, -8) == 'Comments') {
             continue;
         }
         if ($query == '') {
             $query = $q;
         } else {
             $query .= " \n union \n" . $q;
         }
     }
     $ret = 0;
     $res = DB::execute($query);
     if (!$res) {
         return $ret;
     }
     $rows = $res->fetchAll();
     if (!$rows) {
         return $ret;
     }
     foreach ($rows as $row) {
         $value = 0;
         if (isset($row['quantity'])) {
             $value = $row['quantity'];
         }
         $this->data['values'][0]['labels'][] = $row['objectName'];
         $this->data['values'][0]['values'][] = $value;
     }
     //foreach
 }
コード例 #2
0
 static function getSubscriberComments($workspace = null, $tag = null, $orderBy = 'created_on', $orderDir = "DESC", $start = 0, $limit = 20)
 {
     $oc = new ObjectController();
     $queries = $oc->getDashboardObjectQueries($workspace, $tag, false, false, $orderBy);
     $query = '';
     if (!is_array($queries)) {
         return array();
     }
     foreach ($queries as $name => $q) {
         if (str_ends_with($name, "Comments")) {
             if ($query == '') {
                 $query = $q;
             } else {
                 $query .= " \n UNION \n" . $q;
             }
         }
     }
     $query .= " ORDER BY `order_value` ";
     if ($orderDir != "ASC" && $orderDir != "DESC") {
         $orderDir = "DESC";
     }
     $query .= " " . $orderDir . " ";
     $query .= " LIMIT " . $start . "," . $limit . " ";
     $res = DB::execute($query);
     $comments = array();
     if (!$res) {
         return $comments;
     }
     $rows = $res->fetchAll();
     if (!is_array($rows)) {
         return $comments;
     }
     foreach ($rows as $row) {
         $manager = $row['object_manager_value'];
         $id = $row['oid'];
         if ($id && $manager) {
             $comment = get_object_by_manager_and_id($id, $manager);
             $object = $comment->getObject();
             if ($object instanceof ProjectDataObject && $object->isSubscriber(logged_user())) {
                 $comments[] = $comment;
             }
         }
     }
     return $comments;
 }
コード例 #3
0
ファイル: Tags.class.php プロジェクト: pnagaraju25/fengoffice
 /**
  * Return tag names as array ordered by occurrence
  * $order_by sort order, possible values are 'name' and 'count'
  *
  * @access public
  * @return array
  */
 function getTagNames($order_by = 'count')
 {
     $oc = new ObjectController();
     $dqs = $oc->getDashboardObjectQueries();
     $conditions = "";
     foreach ($dqs as $type => $q) {
         if (substr($type, -8) == 'Comments') {
             continue;
         }
         $q = substr($q, strpos($q, "FROM"));
         $q = "`rel_object_id` IN (SELECT `id` {$q}) AND `rel_object_manager` = '{$type}'";
         if ($conditions) {
             $conditions .= " \n\nOR\n\n ";
         }
         $conditions .= $q;
     }
     $query = '';
     switch ($order_by) {
         case 'name':
             $query = 'SELECT DISTINCT `tag` as `name`  FROM ' . self::instance()->getTableName(true) . ' WHERE' . $conditions . ' GROUP BY `tag` ORDER BY  `tag` ';
             break;
         case 'count':
         default:
             $query = 'SELECT DISTINCT `tag` as `name`, count(`tag`) `count` FROM ' . self::instance()->getTableName(true) . ' WHERE' . $conditions . ' GROUP BY `tag` ORDER BY `count` DESC , `tag`';
     }
     $rows = DB::executeAll($query);
     if (!is_array($rows)) {
         return array();
     }
     return $rows;
 }
コード例 #4
0
 static function getLastActivities($project, $tag, $quantity)
 {
     $conditions = "";
     $object_ids = array();
     $queries = ObjectController::getDashboardObjectQueries($project, $tag, false, 'all', null, 'updatedOn', '', 'all');
     $query = '';
     foreach ($queries as $q) {
         $res = DB::execute($q);
         if (!$res) {
             continue;
         }
         $rows = $res->fetchAll();
         if (is_array($rows) && count($rows) > 0) {
             $ids = array();
             $manager = "";
             foreach ($rows as $row) {
                 //$ids .= ($ids == "" ? "" : ",") . $row['oid'];
                 $ids[] = $row['oid'];
                 $manager = $row['object_manager_value'];
             }
             if (isset($object_ids[$manager])) {
                 $object_ids[$manager] = array_merge($object_ids[$manager], $ids);
             } else {
                 $object_ids[$manager] = $ids;
             }
         }
     }
     foreach ($object_ids as $manager => $ids) {
         $ids_str = implode(",", $ids);
         $extra_cond = $manager == 'MailContents' ? "AND `action` <> 'add'" : "";
         $conditions .= ($conditions == "" ? "" : " OR ") . "(`rel_object_manager` = '{$manager}' AND `rel_object_id` IN ({$ids_str}) {$extra_cond})";
     }
     // Show user activity only in root ws
     if (logged_user()->isAdministrator() && $project == null) {
         $conditions .= ($conditions == "" ? "" : " OR ") . "`rel_object_manager` = 'Users'";
     }
     if ($project instanceof Project) {
         $project_ids = $project->getAllSubWorkspacesCSV(true, logged_user());
     } else {
         $project_ids = logged_user()->getActiveProjectIdsCSV();
     }
     $conditions .= ($conditions == "" ? "" : " OR ") . "(`rel_object_manager` = 'Projects' AND `rel_object_id` IN ({$project_ids}))";
     return self::findAll(array('conditions' => $conditions, 'order' => '`created_on` DESC', 'limit' => $quantity));
 }
コード例 #5
0
 /**
  * Counts dashboard objects
  *
  * @return unknown
  */
 private function countTasksAndMilestones($tag = null, $project = null)
 {
     $queries = ObjectController::getDashboardObjectQueries($project, $tag, true);
     $query = $queries['ProjectTasks'] . " UNION " . $queries['ProjectMilestones'];
     $ret = 0;
     $res1 = DB::execute($query);
     if ($res1) {
         $rows = $res1->fetchAll();
         if ($rows) {
             foreach ($rows as $row) {
                 if (isset($row['quantity'])) {
                     $ret += $row['quantity'];
                 }
             }
             //foreach
         }
     }
     return $ret;
 }