本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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
}
示例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);
//.........这里部分代码省略.........
示例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()));
}
示例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;
}
示例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();
}