當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Companies::instance方法代碼示例

本文整理匯總了PHP中Companies::instance方法的典型用法代碼示例。如果您正苦於以下問題:PHP Companies::instance方法的具體用法?PHP Companies::instance怎麽用?PHP Companies::instance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Companies的用法示例。


在下文中一共展示了Companies::instance方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getCompaniesByProjects

 /**
  * Return all companies that are on specific projects, determined by a CVS list of project ids.
  *
  * @access public
  * @param string $projects_csv CSV list of projects
  * @param string $additional_conditions Additional SQL conditions
  * @param bool $include_owner Include the owner company
  * @return array Array of Companies
  */
 static function getCompaniesByProjects($projects_csv, $additional_conditions = null, $include_owner = true)
 {
     $companies = array();
     $companies_table = Companies::instance()->getTableName(true);
     $project_companies_table = ProjectCompanies::instance()->getTableName(true);
     // Restrict result only on owner company
     $ownerCond = '';
     if (!$include_owner) {
         $owner_id = owner_company()->getId();
         $ownerCond = "{$companies_table}.`client_of_id` = '{$owner_id}' AND ";
     }
     $sql = "SELECT {$companies_table}.* FROM {$companies_table}, {$project_companies_table} WHERE {$ownerCond} ({$companies_table}.`id` = {$project_companies_table}.`company_id` AND {$project_companies_table}.`project_id` IN ( " . $projects_csv . '))';
     if (trim($additional_conditions) != '') {
         $sql .= " AND ({$additional_conditions}) ORDER BY {$companies_table}.`name`";
     }
     $rows = DB::executeAll($sql);
     if (is_array($rows)) {
         foreach ($rows as $row) {
             $companies[] = Companies::instance()->loadFromRow($row);
         }
         // foreach
     }
     // if
     return count($companies) ? $companies : null;
 }
開發者ID:pnagaraju25,項目名稱:fengoffice,代碼行數:34,代碼來源:ProjectCompanies.class.php

示例2: getCompaniesByProject

 /**
  * Return all companies that are on specific project. Owner company is excluded from 
  * this listing (only client companies are returned)
  *
  * @access public
  * @param Project $project
  * @param string $additional_conditions Additional SQL conditions
  * @return array
  */
 static function getCompaniesByProject(Project $project, $additional_conditions = null)
 {
     $companies_table = Companies::instance()->getTableName(true);
     $project_companies_table = ProjectCompanies::instance()->getTableName(true);
     // Restrict result only on owner company
     $owner_id = owner_company()->getId();
     $companies = array();
     $sql = "SELECT {$companies_table}.* FROM {$companies_table}, {$project_companies_table} WHERE ({$companies_table}.`client_of_id` = '{$owner_id}') AND ({$companies_table}.`id` = {$project_companies_table}.`company_id` AND {$project_companies_table}.`project_id` = " . DB::escape($project->getId()) . ')';
     if (trim($additional_conditions) != '') {
         $sql .= " AND ({$additional_conditions})";
     }
     $rows = DB::executeAll($sql);
     if (is_array($rows)) {
         foreach ($rows as $row) {
             $companies[] = Companies::instance()->loadFromRow($row);
         }
         // foreach
     }
     // if
     return count($companies) ? $companies : null;
 }
開發者ID:469306621,項目名稱:Languages,代碼行數:30,代碼來源:ProjectCompanies.class.php

示例3: manager

 /**
  * Return manager instance
  *
  * @access protected
  * @param void
  * @return Companies 
  */
 function manager()
 {
     if (!$this->manager instanceof Companies) {
         $this->manager = Companies::instance();
     }
     return $this->manager;
 }
開發者ID:469306621,項目名稱:Languages,代碼行數:14,代碼來源:BaseCompany.class.php

示例4: paginate

 /**
  * 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 arguments (@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, 'Companies')) {
         return parent::paginate($arguments, $items_per_page, $current_page);
     } else {
         return Companies::instance()->paginate($arguments, $items_per_page, $current_page);
         //$instance =& Companies::instance();
         //return $instance->paginate($arguments, $items_per_page, $current_page);
     }
     // if
 }
開發者ID:bklein01,項目名稱:Project-Pier,代碼行數:25,代碼來源:BaseCompanies.class.php

示例5: getDashboardObjectQueries

 /**
  * Returns array of queries that will return Dashboard Objects
  *
  * @param string $proj_ids
  * @param string $tag
  * @param boolean $count if false the query will return objects, if true it will return object count
  */
 static function getDashboardObjectQueries($project = null, $tag = null, $count = false, $trashed = false, $linkedObject = null, $order = 'updatedOn', $filterName = '', $archived = false, $filterManager = '')
 {
     if ($trashed && $trashed !== 'all') {
         $order = 'trashedOn';
     } else {
         if ($archived) {
             $order = 'archivedOn';
         }
     }
     switch ($order) {
         case 'dateCreated':
             $order_crit_companies = '`created_on`';
             $order_crit_contacts = '`created_on`';
             $order_crit_file_revisions = '`created_on`';
             $order_crit_calendar = '`created_on`';
             $order_crit_tasks = '`created_on`';
             $order_crit_milestones = '`created_on`';
             $order_crit_webpages = '`created_on`';
             $order_crit_files = '`created_on`';
             $order_crit_emails = '`received_date`';
             $order_crit_comments = '`created_on`';
             $order_crit_messages = '`created_on`';
             $order_crit_workspaces = '`created_on`';
             break;
         case 'trashedOn':
             $order_crit_companies = '`trashed_on`';
             $order_crit_contacts = '`trashed_on`';
             $order_crit_file_revisions = '`trashed_on`';
             $order_crit_calendar = '`trashed_on`';
             $order_crit_tasks = '`trashed_on`';
             $order_crit_milestones = '`trashed_on`';
             $order_crit_webpages = '`trashed_on`';
             $order_crit_files = '`trashed_on`';
             $order_crit_emails = '`trashed_on`';
             $order_crit_comments = '`trashed_on`';
             $order_crit_messages = '`trashed_on`';
             $order_crit_workspaces = '`updated_on`';
             break;
         case 'archivedOn':
             $order_crit_companies = '`archived_on`';
             $order_crit_contacts = '`archived_on`';
             $order_crit_file_revisions = '`updated_on`';
             $order_crit_calendar = '`archived_on`';
             $order_crit_tasks = '`archived_on`';
             $order_crit_milestones = '`archived_on`';
             $order_crit_webpages = '`archived_on`';
             $order_crit_files = '`archived_on`';
             $order_crit_emails = '`archived_on`';
             $order_crit_comments = '`updated_on`';
             $order_crit_messages = '`archived_on`';
             $order_crit_workspaces = '`completed_on`';
             break;
         case 'name':
             $order_crit_companies = '`name`';
             $order_crit_contacts = "TRIM(CONCAT(' ', `lastname`, `firstname`, `middlename`))";
             $order_crit_file_revisions = "'zzzzzzzzzzzzzz'";
             //Revisar
             $order_crit_calendar = '`subject`';
             $order_crit_tasks = '`title`';
             $order_crit_milestones = '`name`';
             $order_crit_webpages = '`title`';
             $order_crit_files = '`filename`';
             $order_crit_emails = '`subject`';
             $order_crit_comments = '`text`';
             $order_crit_messages = '`title`';
             $order_crit_workspaces = '`name`';
             break;
         default:
             $order_crit_companies = '`updated_on`';
             $order_crit_contacts = '`updated_on`';
             $order_crit_file_revisions = '`updated_on`';
             $order_crit_calendar = '`updated_on`';
             $order_crit_tasks = '`updated_on`';
             $order_crit_milestones = '`updated_on`';
             $order_crit_webpages = '`updated_on`';
             $order_crit_files = '`updated_on`';
             $order_crit_emails = '`received_date`';
             $order_crit_comments = '`updated_on`';
             $order_crit_messages = '`updated_on`';
             $order_crit_workspaces = '`updated_on`';
             break;
     }
     if ($project instanceof Project) {
         $proj_ids = $project->getAllSubWorkspacesQuery(true);
         $proj_cond_companies = Companies::getWorkspaceString($proj_ids);
         $proj_cond_messages = ProjectMessages::getWorkspaceString($proj_ids);
         $proj_cond_documents = ProjectFiles::getWorkspaceString($proj_ids);
         $proj_cond_emails = MailContents::getWorkspaceString($proj_ids);
         $proj_cond_events = ProjectEvents::getWorkspaceString($proj_ids);
         $proj_cond_tasks = ProjectTasks::getWorkspaceString($proj_ids);
         $proj_cond_charts = ProjectCharts::getWorkspaceString($proj_ids);
         $proj_cond_milestones = ProjectMilestones::getWorkspaceString($proj_ids);
         $proj_cond_weblinks = ProjectWebpages::getWorkspaceString($proj_ids);
//.........這裏部分代碼省略.........
開發者ID:pnagaraju25,項目名稱:fengoffice,代碼行數:101,代碼來源:ObjectController.class.php

示例6: canAdd

 /**
  * Returns true if specific user can add client company
  *
  * @access public
  * @param User $user
  * @return boolean
  */
 function canAdd(User $user, Project $project)
 {
     return can_manage_contacts(logged_user()) || can_add($user, $project, get_class(Companies::instance()));
 }
開發者ID:pnagaraju25,項目名稱:fengoffice,代碼行數:11,代碼來源:Company.class.php

示例7: getContactQueries

 private static function getContactQueries($project = null, $tag = null, $count = false, $order = null, $archived = false)
 {
     switch ($order) {
         case 'updatedOn':
             $order_crit_companies = 'updated_on';
             $order_crit_contacts = 'updated_on';
             break;
         case 'createdOn':
             $order_crit_companies = 'created_on';
             $order_crit_contacts = 'created_on';
             break;
         case 'email':
         case 'email2':
         case 'email3':
             $order_crit_contacts = $order;
             $order_crit_companies = $order == 'email' ? 'email' : "' '";
             break;
         default:
             $order_crit_contacts = "TRIM(CONCAT(' ', `lastname`, `firstname`, `middlename`))";
             $order_crit_companies = 'name';
             break;
     }
     if ($project instanceof Project) {
         $proj_ids = $project->getAllSubWorkspacesQuery(!$archived);
         $proj_cond_companies = " AND " . Companies::getWorkspaceString($proj_ids);
         $proj_cond_contacts = " AND " . Contacts::getWorkspaceString($proj_ids);
     } else {
         $proj_cond_companies = "";
         $proj_cond_contacts = "";
     }
     if (isset($tag) && $tag && $tag != '') {
         $tag_str = " AND EXISTS (SELECT * FROM `" . TABLE_PREFIX . "tags` `t` WHERE `tag` = " . DB::escape($tag) . " AND `co`.`id` = `t`.`rel_object_id` AND `t`.`rel_object_manager` = `object_manager_value`) ";
     } else {
         $tag_str = ' ';
     }
     $res = array();
     if ($archived) {
         $archived_cond = "AND `archived_by_id` <> 0";
     } else {
         $archived_cond = "AND `archived_by_id` = 0";
     }
     $permissions = ' AND ( ' . permissions_sql_for_listings(Companies::instance(), ACCESS_LEVEL_READ, logged_user(), '`project_id`', '`co`') . ')';
     $res['Companies'] = "SELECT  {$order_crit_companies} AS `order_value`, 'Companies' AS `object_manager_value`, `id` as `oid` FROM `" . TABLE_PREFIX . "companies` `co` WHERE `trashed_by_id` = 0 {$archived_cond} " . $proj_cond_companies . str_replace('= `object_manager_value`', "= 'Companies'", $tag_str) . $permissions;
     $permissions = ' AND ( ' . permissions_sql_for_listings(Contacts::instance(), ACCESS_LEVEL_READ, logged_user(), '`project_id`', '`co`') . ')';
     $res['Contacts'] = "SELECT {$order_crit_contacts} AS `order_value`, 'Contacts' AS `object_manager_value`, `id` AS `oid` FROM `" . TABLE_PREFIX . "contacts` `co` WHERE `trashed_by_id` = 0 {$archived_cond} {$proj_cond_contacts} " . str_replace('= `object_manager_value`', "= 'Contacts'", $tag_str) . $permissions;
     if ($count) {
         foreach ($res as $p => $q) {
             $res[$p] = "SELECT count(*) AS `quantity`, '{$p}' AS `objectName` FROM ( {$q} ) `table_alias`";
         }
     }
     return $res;
 }
開發者ID:pnagaraju25,項目名稱:fengoffice,代碼行數:52,代碼來源:ContactController.class.php

示例8: getCompanyEmailAddresses

 /**
  * Returns an array of: (name, email)
  * from companies that the logged user can access. 
  * @return array
  */
 function getCompanyEmailAddresses()
 {
     $permissions = permissions_sql_for_listings(Companies::instance(), ACCESS_LEVEL_READ, logged_user());
     $sql = "SELECT `name`, `email` FROM `" . TABLE_PREFIX . "companies` WHERE " . "`trashed_by_id` = 0 AND {$permissions} AND `email` <> ''";
     $all = DB::executeAll($sql);
     if (is_array($all)) {
         return $all;
     }
     return array();
 }
開發者ID:pnagaraju25,項目名稱:fengoffice,代碼行數:15,代碼來源:Companies.class.php


注:本文中的Companies::instance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。