本文整理汇总了PHP中Contacts::findAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Contacts::findAll方法的具体用法?PHP Contacts::findAll怎么用?PHP Contacts::findAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contacts
的用法示例。
在下文中一共展示了Contacts::findAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: new_list_tasks
function new_list_tasks()
{
//load config options into cache for better performance
load_user_config_options_by_category_name('task panel');
$isJson = array_var($_GET, 'isJson', false);
if ($isJson) {
ajx_current("empty");
}
$request_conditions = $this->get_tasks_request_conditions();
$conditions = $request_conditions['conditions'];
$filter_value = $request_conditions['filterValue'];
$filter = $request_conditions['filter'];
$status = $request_conditions['status'];
$tasks = array();
$pendingstr = $status == 0 ? " AND `e`.`completed_on` = " . DB::escape(EMPTY_DATETIME) . " " : "";
$milestone_conditions = " AND `is_template` = false " . $pendingstr;
//Find all internal milestones for these tasks
$internalMilestones = ProjectMilestones::instance()->listing(array("extra_conditions" => $milestone_conditions))->objects;
//Find all external milestones for these tasks, external milestones are the ones that belong to a parent member and have tasks in the current member
$milestone_ids = array();
$task_ids = array();
if ($tasks) {
foreach ($tasks as $task) {
$task_ids[] = $task['id'];
if ($task['milestone_id'] != 0) {
$milestone_ids[$task['milestone_id']] = $task['milestone_id'];
}
}
// generate request cache
ObjectMembers::instance()->getCachedObjectMembers(0, $task_ids);
ProjectTasks::instance()->findByRelatedCached(0, $task_ids);
}
$cp_values = array();
if (count($task_ids) > 0) {
$cp_rows = DB::executeAll("SELECT * FROM " . TABLE_PREFIX . "custom_property_values WHERE object_id IN (" . implode(',', $task_ids) . ")");
if (is_array($cp_rows)) {
foreach ($cp_rows as $row) {
if (!isset($cp_values[$row['object_id']])) {
$cp_values[$row['object_id']] = array();
}
if (!isset($cp_values[$row['object_id']][$row['custom_property_id']])) {
$cp_values[$row['object_id']][$row['custom_property_id']] = array();
}
$cp_values[$row['object_id']][$row['custom_property_id']][] = $row['value'];
}
}
}
tpl_assign('cp_values', $cp_values);
$int_milestone_ids = array();
foreach ($internalMilestones as $milestone) {
$int_milestone_ids[] = $milestone->getId();
}
$milestone_ids = array_diff($milestone_ids, $int_milestone_ids);
if (count($milestone_ids) == 0) {
$milestone_ids[] = 0;
}
$ext_milestone_conditions = " `is_template` = false " . $pendingstr . ' AND `object_id` IN (' . implode(',', $milestone_ids) . ')';
$externalMilestones = ProjectMilestones::findAll(array('conditions' => $ext_milestone_conditions));
// Get Users Info
if (logged_user()->isGuest()) {
$users = array(logged_user());
} else {
$users = allowed_users_in_context(ProjectTasks::instance()->getObjectTypeId(), active_context(), ACCESS_LEVEL_READ, '', true);
}
$allUsers = Contacts::getAllUsers(null, true);
$user_ids = array(-1);
foreach ($allUsers as $user) {
$user_ids[] = $user->getId();
}
// only companies with users
$companies = Contacts::findAll(array("conditions" => "e.is_company = 1", "join" => array("table" => Contacts::instance()->getTableName(), "jt_field" => "object_id", "j_sub_q" => "SELECT xx.object_id FROM " . Contacts::instance()->getTableName(true) . " xx WHERE \r\n\t\t\t\t\txx.is_company=0 AND xx.company_id = e.object_id AND xx.object_id IN (" . implode(",", $user_ids) . ") LIMIT 1")));
tpl_assign('tasks', $tasks);
if (!$isJson) {
$all_templates = COTemplates::findAll(array('conditions' => '`trashed_by_id` = 0 AND `archived_by_id` = 0'));
tpl_assign('all_templates', $all_templates);
if (user_config_option('task_display_limit') > 0 && count($tasks) > user_config_option('task_display_limit')) {
tpl_assign('displayTooManyTasks', true);
array_pop($tasks);
}
tpl_assign('object_subtypes', array());
tpl_assign('internalMilestones', $internalMilestones);
tpl_assign('externalMilestones', $externalMilestones);
tpl_assign('users', $users);
tpl_assign('allUsers', $allUsers);
tpl_assign('companies', $companies);
if (strtotime(user_config_option('tasksDateStart'))) {
//this return null if date is 0000-00-00 00:00:00
$dateStart = new DateTime('@' . strtotime(user_config_option('tasksDateStart')));
$dateStart = $dateStart->format(user_config_option('date_format'));
} else {
$dateStart = '';
}
if (strtotime(user_config_option('tasksDateEnd'))) {
//this return null if date is 0000-00-00 00:00:00
$dateEnd = new DateTime('@' . strtotime(user_config_option('tasksDateEnd')));
$dateEnd = $dateEnd->format(user_config_option('date_format'));
} else {
$dateEnd = '';
}
$userPref = array();
//.........这里部分代码省略.........
示例2: list_users
function list_users() {
$this->setTemplate(get_template_path("json"));
ajx_current("empty");
$usr_data = array();
$users = Contacts::findAll(array("conditions"=>"is_company = 0"));
if ($users) {
foreach ($users as $usr) {
$usr_data[] = array(
"id" => $usr->getId(),
"name" => $usr->getObjectName()
);
}
}
$extra = array();
$extra['users'] = $usr_data;
ajx_extra_data($extra);
}
示例3: allowed_users_to_assign_all
function allowed_users_to_assign_all($context = null)
{
if ($context == null) {
$context = active_context();
}
// only companies with users
$companies = Contacts::findAll(array("conditions" => "e.is_company = 1 AND EXISTS (SELECT object_id FROM " . TABLE_PREFIX . "contacts WHERE is_company = 0 AND user_type > 0 AND company_id = o.id )", "join" => array("table" => Contacts::instance()->getTableName(), "jt_field" => "object_id", "j_sub_q" => "SELECT xx.object_id FROM " . Contacts::instance()->getTableName(true) . " xx WHERE xx.is_company=0 AND xx.company_id = e.object_id LIMIT 1"), "order" => "name"));
$comp_ids = array("0");
$comp_array = array("0" => array('id' => "0", 'name' => lang('without company'), 'users' => array()));
foreach ($companies as $company) {
$comp_ids[] = $company->getId();
$comp_array[$company->getId()] = array('id' => $company->getId(), 'name' => $company->getObjectName(), 'users' => array());
}
if (!can_manage_tasks(logged_user()) && can_task_assignee(logged_user())) {
$contacts = array(logged_user());
} else {
if (can_manage_tasks(logged_user())) {
$contacts = allowed_users_in_context(ProjectTasks::instance()->getObjectTypeId(), $context, ACCESS_LEVEL_READ, "AND `is_company`=0 AND `company_id` IN (" . implode(",", $comp_ids) . ")");
} else {
$contacts = array();
}
}
foreach ($contacts as $contact) {
/* @var $contact Contact */
if (TabPanelPermissions::instance()->count(array("conditions" => "permission_group_id = " . $contact->getPermissionGroupId() . " AND tab_panel_id = 'tasks-panel' "))) {
$comp_array[]['users'][] = array('id' => $contact->getId(), 'name' => $contact->getObjectName(), 'isCurrent' => $contact->getId() == logged_user()->getId());
}
}
return array_values($comp_array);
}
示例4: array
$mnames = array();
$allowed_contact_ids = array();
foreach ($active_members as $member) {
$allowed_contact_ids[] = $member->getAllowedContactIds();
$mnames[] = clean($member->getName());
}
$intersection = $allowed_contact_ids[0];
if (count($allowed_contact_ids) > 1) {
for ($i = 1; $i < count($allowed_contact_ids); $i++) {
$intersection = array_intersect($intersection, $allowed_contact_ids[$i]);
}
}
$contacts = Contacts::findAll(array(
'conditions' => 'object_id IN ('.implode(',',$intersection).') AND `is_company` = 0 AND disabled = 0',
'limit' => $limit,
'order' => 'last_activity, updated_on',
'order_dir' => 'desc',
));
$total = count($contacts);
$widget_title = lang("people in", implode(", ", $mnames));
} else {
$result = Contacts::instance()->listing(array(
"order" => "last_activity, updated_on",
"order_dir" => "desc",
"extra_conditions" => " AND `is_company` = 0 AND disabled = 0 AND user_type > 0",
"start" => 0,
"limit" => $limit
));
示例5: new_list_tasks
//.........这里部分代码省略.........
$task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `due_date` <= '{$now}'";
break;
case 20:
// Actives task by current user
$task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `start_date` <= '{$now}' AND `assigned_to_contact_id` = " . logged_user()->getId();
break;
case 21:
// Subscribed tasks by current user
$res20 = DB::execute("SELECT object_id FROM " . TABLE_PREFIX . "object_subscriptions WHERE `contact_id` = " . logged_user()->getId());
$subs_rows = $res20->fetchAll($res20);
foreach ($subs_rows as $row) {
$subs[] = $row['object_id'];
}
unset($res20, $subs_rows, $row);
$task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `id` IN(" . implode(',', $subs) . ")";
break;
case 2:
// All tasks
break;
default:
throw new Exception('Task status "' . $status . '" not recognised');
}
$conditions = "AND {$template_condition} {$task_filter_condition} {$task_status_condition}";
//Now get the tasks
//$tasks = ProjectTasks::getContentObjects(active_context(), ObjectTypes::findById(ProjectTasks::instance()->getObjectTypeId()), null, null, $conditions,null)->objects;
$tasks = ProjectTasks::instance()->listing(array("extra_conditions" => $conditions, "start" => 0, "limit" => 501, "count_results" => false))->objects;
$pendingstr = $status == 0 ? " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " " : "";
$milestone_conditions = " AND `is_template` = false " . $pendingstr;
//Find all internal milestones for these tasks
//$internalMilestones = ProjectMilestones::getContentObjects(active_context(), ObjectTypes::findById(ProjectMilestones::instance()->getObjectTypeId()), null, null, $milestone_conditions,null)->objects;
$internalMilestones = ProjectMilestones::instance()->listing(array("extra_conditions" => $milestone_conditions))->objects;
//Find all external milestones for these tasks, external milestones are the ones that belong to a parent member and have tasks in the current member
$milestone_ids = array();
if ($tasks) {
foreach ($tasks as $task) {
if ($task->getMilestoneId() != 0) {
$milestone_ids[$task->getMilestoneId()] = $task->getMilestoneId();
}
}
}
$int_milestone_ids = array();
foreach ($internalMilestones as $milestone) {
$int_milestone_ids[] = $milestone->getId();
}
$milestone_ids = array_diff($milestone_ids, $int_milestone_ids);
if (count($milestone_ids) == 0) {
$milestone_ids[] = 0;
}
$ext_milestone_conditions = " `is_template` = false " . $pendingstr . ' AND `object_id` IN (' . implode(',', $milestone_ids) . ')';
$externalMilestones = ProjectMilestones::findAll(array('conditions' => $ext_milestone_conditions));
// Get Users Info
$users = allowed_users_in_context(ProjectTasks::instance()->getObjectTypeId(), active_context(), ACCESS_LEVEL_READ);
$allUsers = Contacts::getAllUsers();
$user_ids = array(-1);
foreach ($users as $user) {
$user_ids[] = $user->getId();
}
// only companies with users
$companies = Contacts::findAll(array("conditions" => "e.is_company = 1", "join" => array("table" => Contacts::instance()->getTableName(), "jt_field" => "object_id", "j_sub_q" => "SELECT xx.object_id FROM " . Contacts::instance()->getTableName(true) . " xx WHERE \n\t\t\t\t\txx.is_company=0 AND xx.company_id = e.object_id AND xx.object_id IN (" . implode(",", $user_ids) . ") LIMIT 1")));
tpl_assign('tasks', $tasks);
if (config_option('use tasks dependencies')) {
$dependency_count = array();
foreach ($tasks as $task) {
$previous = 0;
$ptasks = ProjectTaskDependencies::getDependenciesForTask($task->getId());
foreach ($ptasks as $pdep) {
$ptask = ProjectTasks::findById($pdep->getPreviousTaskId());
if ($ptask instanceof ProjectTask && !$ptask->isCompleted()) {
$previous++;
}
}
$dependants = ProjectTaskDependencies::getDependantsForTask($task->getId());
$dep_csv = "";
foreach ($dependants as $dep) {
$dep_csv .= ($dep_csv == "" ? "" : ",") . $dep->getTaskId();
}
$dependency_count[] = array('id' => $task->getId(), 'count' => $previous, 'dependants' => $dep_csv);
}
tpl_assign('dependency_count', $dependency_count);
}
if (!$isJson) {
$all_templates = COTemplates::findAll(array('conditions' => '`trashed_by_id` = 0 AND `archived_by_id` = 0'));
tpl_assign('all_templates', $all_templates);
if (user_config_option('task_display_limit') > 0 && count($tasks) > user_config_option('task_display_limit')) {
tpl_assign('displayTooManyTasks', true);
array_pop($tasks);
}
tpl_assign('object_subtypes', array());
tpl_assign('internalMilestones', $internalMilestones);
tpl_assign('externalMilestones', $externalMilestones);
tpl_assign('users', $users);
tpl_assign('allUsers', $allUsers);
tpl_assign('companies', $companies);
$userPref = array();
$userPref = array('filterValue' => isset($filter_value) ? $filter_value : '', 'filter' => $filter, 'status' => $status, 'showWorkspaces' => user_config_option('tasksShowWorkspaces', 1), 'showTime' => user_config_option('tasksShowTime'), 'showDates' => user_config_option('tasksShowDates'), 'showTags' => user_config_option('tasksShowTags', 0), 'showEmptyMilestones' => user_config_option('tasksShowEmptyMilestones', 1), 'showTimeEstimates' => user_config_option('tasksShowTimeEstimates', 1), 'groupBy' => user_config_option('tasksGroupBy', 'milestone'), 'orderBy' => user_config_option('tasksOrderBy', 'priority'), 'defaultNotifyValue' => user_config_option('can notify from quick add'));
hook::fire('tasks_user_preferences', null, $userPref);
tpl_assign('userPreferences', $userPref);
ajx_set_no_toolbar(true);
}
}
示例6: getContacts
/**
* Return array of all company members
*
* @access public
* @param void
* @return array
*/
function getContacts()
{
return Contacts::findAll(array('conditions' => '`company_id` = ' . DB::escape($this->getId()), 'order' => '`display_name` ASC'));
// findAll
}
示例7: getClientCompanies
/**
* Return all client companies
*
* @access public
* @param void
* @return array
*/
function getClientCompanies()
{
return Contacts::findAll(array('conditions' => '`object_id` <> 1 AND `is_company` = 1'));
}
示例8: edit_account
//.........这里部分代码省略.........
try {
$user_changed = false;
$selected_user = array_var($_POST, 'users_select_box');
if (!$is_admin){
$mail_account_user = Contacts::findById($mailAccount->getContactId());
}
else{
$mail_account_user = Contacts::findById($selected_user);
$old_user_id = $mailAccount->getContactId();
if ($old_user_id != $mail_account_user->getId())
$user_changed = true;
}
$mailAccount_data['user_id'] = $mail_account_user->getId();
$mailAccount_data['sync_ssl'] = array_var($mailAccount_data, 'sync_ssl') == "checked";
DB::beginWork();
$logged_user_settings = MailAccountContacts::getByAccountAndContact($mailAccount, logged_user());
$logged_user_can_edit = $logged_user_settings instanceof MailAccountContact && $logged_user_settings->getCanEdit() || $mailAccount->getContactId() == logged_user()->getId();
if ($logged_user_can_edit) {
if (!array_var($mailAccount_data, 'del_mails_from_server', false)) $mailAccount_data['del_from_server'] = 0;
$mailAccount->setFromAttributes($mailAccount_data);
$mailAccount->setPassword(MailUtilities::ENCRYPT_DECRYPT($mailAccount->getPassword()));
$mailAccount->setSmtpPassword(MailUtilities::ENCRYPT_DECRYPT($mailAccount->getSmtpPassword()));
$outbox_folder = array_var($_POST, 'outbox_select_box');
if (config_option("sent_mails_sync") && isset($outbox_folder)){
$mailAccount->setSyncPass(MailUtilities::ENCRYPT_DECRYPT($mailAccount_data['sync_pass']));
$mailAccount->setSyncFolder($outbox_folder);
}
//in case there is a new owner of the email account
if ($user_changed){
$conditions = array("conditions" => "`created_by_id` = '$old_user_id' AND `account_id` = ".$mailAccount->getId()."");
$all_emails = MailContents::findAll($conditions);
foreach ($all_emails as $e){
$e->setCreatedById($mail_account_user->getId());
$e->save();
}
}
//If imap, save folders to check
if($mailAccount->getIsImap() && is_array(array_var($_POST, 'check'))) {
$checks = array_var($_POST, 'check');
if (is_array($imap_folders) && count($imap_folders)) {
foreach ($imap_folders as $folder) {
$folder->setCheckFolder(false);
foreach ($checks as $name => $cf) {
$name = str_replace(array('¡','!'), array('[',']'), $name);//to avoid a mistaken array if name contains [
if (strcasecmp($name, $folder->getFolderName()) == 0) {
$folder->setCheckFolder($cf == 'checked');
break;
}
}
$folder->save();
}
}
}
$member_ids = json_decode(array_var($_POST, 'members'));
if ( count($member_ids) > 0 ){
$member = $member_ids[0];
}else{
$member = 0;
}
$mailAccount->setMemberId($member);
示例9: permission_member_form_parameters
function permission_member_form_parameters($member = null)
{
if ($member) {
$dim = $member->getDimension();
} elseif (array_var($_REQUEST, 'dim_id')) {
$dim = Dimensions::getDimensionById(array_var($_REQUEST, 'dim_id'));
}
if (logged_user()->isMemberOfOwnerCompany()) {
$companies = Contacts::findAll(array("conditions" => "is_company = 1", 'order' => 'name'));
} else {
$companies = array(owner_company());
if (logged_user()->getCompany() instanceof Contact) {
$companies[] = logged_user()->getCompany();
}
}
$allowed_object_types = array();
$dim_obj_types = $dim->getAllowedObjectTypeContents();
foreach ($dim_obj_types as $dim_obj_type) {
// To draw a row for each object type of the dimension
if (!array_key_exists($dim_obj_type->getContentObjectTypeId(), $allowed_object_types) && (!$member || $dim_obj_type->getDimensionObjectTypeId() == $member->getObjectTypeId())) {
$allowed_object_types[$dim_obj_type->getContentObjectTypeId()] = ObjectTypes::findById($dim_obj_type->getContentObjectTypeId());
$allowed_object_types_json[] = $dim_obj_type->getContentObjectTypeId();
}
}
$permission_groups = array();
foreach ($companies as $company) {
$users = $company->getUsersByCompany();
foreach ($users as $u) {
$permission_groups[] = $u->getPermissionGroupId();
}
}
$no_company_users = Contacts::getAllUsers("AND `company_id` = 0", true);
foreach ($no_company_users as $noc_user) {
$permission_groups[] = $noc_user->getPermissionGroupId();
}
$non_personal_groups = PermissionGroups::getNonRolePermissionGroups();
foreach ($non_personal_groups as $group) {
$permission_groups[] = $group->getId();
}
foreach ($permission_groups as $pg_id) {
if ($dim->hasAllowAllForContact($pg_id)) {
$member_permissions[$pg_id] = array();
foreach ($dim_obj_types as $dim_obj_type) {
if ($member && $dim_obj_type->getDimensionObjectTypeId() == $member->getObjectTypeId()) {
$member_permissions[$pg_id][] = array('o' => $dim_obj_type->getContentObjectTypeId(), 'w' => 1, 'd' => 1, 'r' => 1);
} elseif (!$member) {
// WHEN CREATING a new member dont allow any user
$member_permissions[$pg_id][] = array('o' => $dim_obj_type->getContentObjectTypeId(), 'w' => 0, 'd' => 0, 'r' => 0);
}
}
} else {
if (!$dim->deniesAllForContact($pg_id)) {
$member_permissions[$pg_id] = array();
if ($member) {
$mpgs = ContactMemberPermissions::findAll(array("conditions" => array("`permission_group_id` = ? AND `member_id` = ?", $pg_id, $member->getId())));
if (is_array($mpgs)) {
foreach ($mpgs as $mpg) {
$member_permissions[$mpg->getPermissionGroupId()][] = array('o' => $mpg->getObjectTypeId(), 'w' => $mpg->getCanWrite() ? 1 : 0, 'd' => $mpg->getCanDelete() ? 1 : 0, 'r' => 1);
}
}
}
}
}
}
return array('member' => $member, 'allowed_object_types' => $allowed_object_types, 'allowed_object_types_json' => $allowed_object_types_json, 'permission_groups' => $permission_groups, 'member_permissions' => $member_permissions);
}
示例10: permission_member_form_parameters
function permission_member_form_parameters($member = null, $dimension_id = null) {
if ( $member ) {
$dim = $member->getDimension();
}elseif (array_var( $_REQUEST,'dim_id')) {
$dim = Dimensions::getDimensionById(array_var( $_REQUEST,'dim_id'));
}elseif (!is_null($dimension_id)) {
$dim = Dimensions::getDimensionById($dimension_id);
}
if (!$dim instanceof Dimension) {
Logger::log("Invalid dimension: " . ($member instanceof Member ? " for member ".$member->getId() : "request: ".print_r($_REQUEST, 1)));
throw new Exception("Invalid dimension");
}
if (logged_user()->isMemberOfOwnerCompany()) {
$companies = Contacts::findAll(array("conditions" => "is_company = 1 AND object_id IN (SELECT company_id FROM ".TABLE_PREFIX."contacts WHERE user_type>0 AND disabled=0)", 'order' => 'first_name'));
} else {
$companies = array(owner_company());
if (logged_user()->getCompany() instanceof Contact) $companies[] = logged_user()->getCompany();
}
$allowed_object_types = array();
$dim_obj_types = $dim->getAllowedObjectTypeContents();
foreach ($dim_obj_types as $dim_obj_type) {
// To draw a row for each object type of the dimension
if ( !array_key_exists($dim_obj_type->getContentObjectTypeId(), $allowed_object_types) && (!$member || $dim_obj_type->getDimensionObjectTypeId() == $member->getObjectTypeId()) ) {
$allowed_object_types[$dim_obj_type->getContentObjectTypeId()] = ObjectTypes::findById($dim_obj_type->getContentObjectTypeId());
$allowed_object_types_json[] = $dim_obj_type->getContentObjectTypeId();
}
}
$permission_groups = array();
foreach ($companies as $company) {
$users = $company->getUsersByCompany();
foreach ($users as $u) $permission_groups[] = $u->getPermissionGroupId();
}
$no_company_users = Contacts::getAllUsers("AND `company_id` = 0", true);
foreach ($no_company_users as $noc_user) {
$permission_groups[] = $noc_user->getPermissionGroupId();
}
$non_personal_groups = PermissionGroups::getNonRolePermissionGroups();
foreach ($non_personal_groups as $group) {
$permission_groups[] = $group->getId();
}
foreach ($permission_groups as $pg_id) {
if ($dim->hasAllowAllForContact($pg_id)) {
$member_permissions[$pg_id] = array();
foreach ($dim_obj_types as $dim_obj_type) {
if ($member && $dim_obj_type->getDimensionObjectTypeId() == $member->getObjectTypeId()) {
$member_permissions[$pg_id][] = array(
'o' => $dim_obj_type->getContentObjectTypeId(),
'w' => 1,
'd' => 1,
'r' => 1
);
}elseif(!$member){
// WHEN CREATING a new member dont allow any user
$member_permissions[$pg_id][] = array(
'o' => $dim_obj_type->getContentObjectTypeId(),
'w' => 0,
'd' => 0,
'r' => 0
);
}
}
} else if (!$dim->deniesAllForContact($pg_id)) {
$member_permissions[$pg_id] = array();
if ($member) {
$mpgs = ContactMemberPermissions::findAll(array("conditions" => array("`permission_group_id` = ? AND `member_id` = ?", $pg_id, $member->getId())));
if (is_array($mpgs)) {
foreach ($mpgs as $mpg) {
$member_permissions[$mpg->getPermissionGroupId()][] = array(
'o' => $mpg->getObjectTypeId(),
'w' => $mpg->getCanWrite() ? 1 : 0,
'd' => $mpg->getCanDelete() ? 1 : 0,
'r' => 1
);
}
}
}
}
}
return array(
'member' => $member,
'allowed_object_types' => $allowed_object_types,
'allowed_object_types_json' => $allowed_object_types_json,
'permission_groups' => $permission_groups,
'member_permissions' => $member_permissions,
);
}
示例11: getCategoryUsers
function getCategoryUsers() {
return Contacts::findAll(array('conditions' => 'default_billing_id = ' . $this->getId()));
}
示例12: get_default_member_permission
function get_default_member_permission($parent, $permission_parameters)
{
//inherit permission from parent
if ($parent != 0 && config_option('inherit_permissions_from_parent_member')) {
$parent_member = Members::getMemberById($parent);
if ($parent_member instanceof Member) {
$parent_permissions = permission_member_form_parameters($parent_member);
$permission_parameters['permission_groups'] = $parent_permissions['permission_groups'];
$permission_parameters['member_permissions'] = $parent_permissions['member_permissions'];
}
}
// Add default permissions for executives, managers and administrators
if (config_option('add_default_permissions_for_users')) {
if ($parent == 0) {
$user_types = implode(',', config_option('give_member_permissions_to_new_users'));
if (trim($user_types) != "") {
$users = Contacts::findAll(array('conditions' => "user_type IN (" . $user_types . ")"));
foreach ($users as $user) {
if (!isset($permission_parameters['member_permissions'][$user->getPermissionGroupId()]) || count($permission_parameters['member_permissions'][$user->getPermissionGroupId()]) == 0) {
$user_pg = array();
foreach ($permission_parameters['allowed_object_types'] as $ot) {
$role_perm = RoleObjectTypePermissions::findOne(array('conditions' => array("role_id=? AND object_type_id=?", $user->getUserType(), $ot->getId())));
$user_pg[] = array('o' => $ot->getId(), 'w' => $role_perm instanceof RoleObjectTypePermission ? $role_perm->getCanWrite() ? 1 : 0 : 0, 'd' => $role_perm instanceof RoleObjectTypePermission ? $role_perm->getCanDelete() ? 1 : 0 : 0, 'r' => $role_perm instanceof RoleObjectTypePermission ? 1 : 0);
}
$permission_parameters['member_permissions'][$user->getPermissionGroupId()] = $user_pg;
}
}
}
}
}
return $permission_parameters;
}
示例13: unset
if ($v == '') {
unset($intersection[$k]);
}
}
//user to display on the widget
$intersection_condition = count($intersection) > 0 ? 'object_id IN (' . implode(',', $intersection) . ') AND' : '';
$intersection_condition = "";
$result = Contacts::instance()->listing(array("order" => $order, "order_dir" => "DESC", "extra_conditions" => " AND `is_company` = 0 AND disabled = 0", "start" => 0, "limit" => $limit));
$total = $result->total;
$contacts = $result->objects;
$contacts_for_combo = null;
//if logged user can assign permissions
if (can_manage_security(logged_user())) {
//users to display on the combo
$intersection_condition = count($intersection) > 0 ? 'o.id NOT IN (' . implode(',', $intersection) . ') AND' : '';
$contacts_for_combo = Contacts::findAll(array('conditions' => $intersection_condition . ' `is_company` = 0 AND `user_type` > ' . logged_user()->getUserType() . ' AND disabled = 0', 'order' => 'first_name', 'order_dir' => 'desc'));
}
//add people button name
if (isset($mnames[0])) {
$add_people_btn = true;
}
//widget title
$widget_title = lang("users in", implode(", ", $mnames));
$mids = implode(",", $mids);
} else {
$widget_title = lang("users");
$result = Contacts::instance()->listing(array("order" => $order, "order_dir" => "DESC", "extra_conditions" => " AND `is_company` = 0 AND disabled = 0 AND `user_type` > 0", "start" => 0, "limit" => $limit));
$total = $result->total;
$contacts = $result->objects;
}
$render_add = can_manage_security(logged_user());
示例14: getContacts
function getContacts()
{
return Contacts::findAll(array('conditions' => '`company_id` = ' . DB::escape($this->getId())));
// findAll
}
示例15: core_dimensions_after_save_member_permissions
function core_dimensions_after_save_member_permissions($member, &$ignored) {
if (!$member instanceof Member || !($member->getId()>0)) return;
$permission_group_ids = array();
$cmp_rows = DB::executeAll("SELECT DISTINCT permission_group_id FROM ".TABLE_PREFIX."contact_member_permissions WHERE member_id = '".$member->getId()."' AND permission_group_id IN (SELECT id FROM ".TABLE_PREFIX."permission_groups WHERE type IN ('permission_groups','user_groups'))");
foreach ($cmp_rows as $row) {
$permission_group_ids[$row['permission_group_id']] = $row['permission_group_id'];
}
$contacts = array();
// users
if (count($permission_group_ids) > 0) {
$contacts = Contacts::findAll(array('conditions' => 'user_type > 0 && permission_group_id IN ('.implode(',', $permission_group_ids).')'));
}
// contacts
$contact_rows = DB::executeAll("SELECT DISTINCT om.object_id FROM ".TABLE_PREFIX."object_members om INNER JOIN ".TABLE_PREFIX."contacts c ON c.object_id=om.object_id
WHERE om.member_id='".$member->getId()."' AND c.user_type=0");
$no_user_ids = array();
if (is_array($contact_rows)) {
foreach ($contact_rows as $row) {
$no_user_ids[] = $row['object_id'];
}
}
$more_contacts = Contacts::findAll(array('conditions' => 'object_id IN ('.implode(',', $no_user_ids).')'));
$contacts = array_merge($contacts, $more_contacts);
$contact_ids = array(0);
$persons_dim = Dimensions::findByCode("feng_persons");
core_dim_remove_contacts_member_associations($member);
foreach ($contacts as $contact) {
$contact_id = $contact->getId();
$contact_member = Members::findOneByObjectId($contact_id, $persons_dim->getId());
if ($contact_member instanceof Member) {
core_dim_add_contact_member_associations($contact_member, $member);
if ($contact instanceof Contact && $contact->isUser()) {
$has_project_permissions = ContactMemberPermissions::instance()->count("permission_group_id = '".$contact->getPermissionGroupId()."' AND member_id = ".$member->getId()) > 0;
if (!$has_project_permissions) {
RoleObjectTypePermissions::createDefaultUserPermissions($contact, $member);
}
}
}
// add user content object to customer member
ObjectMembers::addObjectToMembers($contact_id, array($member));
$contact->addToSharingTable();
$contact_ids[] = $contact_id;
}
// remove contacts whose members are no longer associated to the customer member
$previous_users_in_member = Contacts::instance()->listing(array(
'member_ids' => array($member->getId()),
'ignore_context' => true,
'extra_conditions' => ' AND e.user_type > 0 AND e.object_id NOT IN ('.implode(',', $contact_ids).')',
))->objects;
foreach ($previous_users_in_member as $prev_u) {
ObjectMembers::removeObjectFromMembers($prev_u, logged_user(), array($member), array($member->getId()));
}
// refresh dimensions
evt_add("reload dimension tree", array('dim_id' => $persons_dim->getId(), 'node' => null));
}