本文整理汇总了PHP中Contacts::getAllUsers方法的典型用法代码示例。如果您正苦于以下问题:PHP Contacts::getAllUsers方法的具体用法?PHP Contacts::getAllUsers怎么用?PHP Contacts::getAllUsers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contacts
的用法示例。
在下文中一共展示了Contacts::getAllUsers方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: afterMemberPermissionChanged
/**
*
* @param array $permissions with the member and the changed_pgs
*/
function afterMemberPermissionChanged($permissions)
{
$member = array_var($permissions, 'member');
//get all users in the set of permissions groups
$permissionGroupIds = array();
foreach (array_var($permissions, 'changed_pgs') as $pg_id) {
$permissionGroupId = $pg_id;
if (!in_array($permissionGroupId, $permissionGroupIds)) {
$permissionGroupIds[] = $permissionGroupId;
}
}
if (count($permissionGroupIds) > 0) {
$usersIds = ContactPermissionGroups::getAllContactsIdsByPermissionGroupIds($permissionGroupIds);
foreach ($usersIds as $us_id) {
$user = Contacts::findById($us_id);
ContactMemberCaches::updateContactMemberCache($user, $member->getId());
}
} else {
//update this member for all user in cache
$contacts = Contacts::getAllUsers();
foreach ($contacts as $contact) {
ContactMemberCaches::updateContactMemberCache($contact, $member->getId());
}
}
}
示例2: edit
/**
* Edit group
*
* @param void
* @return null
*/
function edit()
{
$this->setTemplate('add');
if (!can_manage_security(logged_user())) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
// if
$group = PermissionGroups::findById(get_id());
if (!$group instanceof PermissionGroup) {
flash_error(lang('group dnx'));
$this->redirectTo('administration', 'groups');
}
// if
$group_data = array_var($_POST, 'group');
if (!is_array($group_data)) {
$pg_id = $group->getId();
$parameters = permission_form_parameters($pg_id);
// Module Permissions
$module_permissions = TabPanelPermissions::findAll(array("conditions" => "`permission_group_id` = {$pg_id}"));
$module_permissions_info = array();
foreach ($module_permissions as $mp) {
$module_permissions_info[$mp->getTabPanelId()] = 1;
}
$all_modules = TabPanels::findAll(array("conditions" => "`enabled` = 1", "order" => "ordering"));
$all_modules_info = array();
foreach ($all_modules as $module) {
$all_modules_info[] = array('id' => $module->getId(), 'name' => lang($module->getTitle()), 'ot' => $module->getObjectTypeId());
}
// System Permissions
$system_permissions = SystemPermissions::findById($pg_id);
tpl_assign('module_permissions_info', $module_permissions_info);
tpl_assign('all_modules_info', $all_modules_info);
tpl_assign('system_permissions', $system_permissions);
tpl_assign('permission_parameters', $parameters);
// users
$group_users = array();
$cpgs = ContactPermissionGroups::findAll(array("conditions" => "`permission_group_id` = {$pg_id}"));
foreach ($cpgs as $cpg) {
$group_users[] = $cpg->getContactId();
}
tpl_assign('groupUserIds', $group_users);
tpl_assign('users', Contacts::getAllUsers());
tpl_assign('pg_id', $group->getId());
tpl_assign('group', $group);
tpl_assign('group_data', array('name' => $group->getName()));
add_page_action(lang('delete'), "javascript:if(confirm(lang('confirm delete group'))) og.openLink('" . $group->getDeleteUrl() . "');", 'ico-trash', null, null, true);
} else {
try {
$group->setFromAttributes($group_data);
DB::beginWork();
$group->save();
// set permissions
$pg_id = $group->getId();
//save_permissions($pg_id);
$gr_users = $group->getUsers();
$gr_users_ids = array();
if ($post_users = array_var($_POST, 'user')) {
foreach ($post_users as $user_id => $val) {
if ($val == '1' && is_numeric($user_id)) {
$gr_users_ids[] = $user_id;
}
}
}
foreach ($gr_users as $us) {
if (!in_array($us->getId(), $gr_users_ids)) {
$gr_users_ids[] = $us->getId();
}
}
// save users
ContactPermissionGroups::delete("`permission_group_id` = {$pg_id}");
if ($users = array_var($_POST, 'user')) {
foreach ($users as $user_id => $val) {
if ($val == '1' && is_numeric($user_id) && Contacts::findById($user_id) instanceof Contact) {
$cpg = new ContactPermissionGroup();
$cpg->setPermissionGroupId($pg_id);
$cpg->setContactId($user_id);
$cpg->save();
}
}
}
//ApplicationLogs::createLog($group, ApplicationLogs::ACTION_EDIT);
DB::commit();
flash_success(lang('success edit group', $group->getName()));
ajx_current("back");
} catch (Exception $e) {
DB::rollback();
tpl_assign('error', $e);
return;
}
try {
save_user_permissions_background(logged_user(), $pg_id, false, $gr_users_ids);
} catch (Exception $e) {
//.........这里部分代码省略.........
示例3: 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();
//.........这里部分代码省略.........
示例4: get_ext_values
private function get_ext_values($field, $manager = null)
{
$values = array(array('id' => '', 'name' => '-- ' . lang('select') . ' --'));
if ($field == 'contact_id' || $field == 'created_by_id' || $field == 'updated_by_id' || $field == 'assigned_to_contact_id' || $field == 'completed_by_id' || $field == 'approved_by_id') {
$users = Contacts::getAllUsers();
foreach ($users as $user) {
$values[] = array('id' => $user->getId(), 'name' => $user->getObjectName());
}
} else {
if ($field == 'milestone_id') {
$milestones = ProjectMilestones::getActiveMilestonesByUser(logged_user());
foreach ($milestones as $milestone) {
$values[] = array('id' => $milestone->getId(), 'name' => $milestone->getObjectName());
}
/*} else if($field == 'object_subtype'){
$object_types = ProjectCoTypes::findAll(array('conditions' => (!is_null($manager) ? "`object_manager`='$manager'" : "")));
foreach($object_types as $object_type){
$values[] = array('id' => $object_type->getId(), 'name' => $object_type->getName());
}*/
}
}
return $values;
}
示例5: index
function index()
{
$tasksUserId = array_var($_GET, 'tu');
if (is_null($tasksUserId)) {
$tasksUserId = user_config_option('TM tasks user filter', logged_user()->getId());
} else {
if (user_config_option('TM tasks user filter') != $tasksUserId) {
set_user_config_option('TM tasks user filter', $tasksUserId, logged_user()->getId());
}
}
$timeslotsUserId = array_var($_GET, 'tsu');
if (is_null($timeslotsUserId)) {
$timeslotsUserId = user_config_option('TM user filter', 0);
} else {
if (user_config_option('TM user filter') != $timeslotsUserId) {
set_user_config_option('TM user filter', $timeslotsUserId, logged_user()->getId());
}
}
$showTimeType = array_var($_GET, 'stt');
if (is_null($showTimeType)) {
$showTimeType = user_config_option('TM show time type', 0);
} else {
if (user_config_option('TM show time type') != $showTimeType) {
set_user_config_option('TM show time type', $showTimeType, logged_user()->getId());
}
}
$start = array_var($_GET, 'start', 0);
$limit = 20;
$tasksUser = Contacts::findById($tasksUserId);
$timeslotsUser = Contacts::findById($timeslotsUserId);
//Active tasks view
$open_timeslots = Timeslots::instance()->listing(array("extra_conditions" => " AND end_time = '" . EMPTY_DATETIME . "' AND contact_id = " . $tasksUserId))->objects;
$tasks = array();
foreach ($open_timeslots as $open_timeslot) {
$task = ProjectTasks::findById($open_timeslot->getRelObjectId());
if ($task instanceof ProjectTask && !$task->isCompleted() && !$task->isTrashed() && !$task->isArchived()) {
$tasks[] = $task;
}
}
ProjectTasks::populateTimeslots($tasks);
//Timeslots view
$total = 0;
switch ($showTimeType) {
case 0:
//Show only timeslots added through the time panel
$result = Timeslots::getGeneralTimeslots(active_context(), $timeslotsUser, $start, $limit);
$timeslots = $result->objects;
$total = $result->total;
break;
default:
throw new Error('Unrecognised TM show time type: ' . $showTimeType);
}
//Get Users Info
$users = array();
$context = active_context();
if (!can_manage_time(logged_user())) {
if (can_add(logged_user(), $context, Timeslots::instance()->getObjectTypeId())) {
$users = array(logged_user());
}
} else {
if (logged_user()->isMemberOfOwnerCompany()) {
$users = Contacts::getAllUsers();
} else {
$users = logged_user()->getCompanyId() > 0 ? Contacts::getAllUsers(" AND `company_id` = " . logged_user()->getCompanyId()) : array(logged_user());
}
$tmp_users = array();
foreach ($users as $user) {
if (can_add($user, $context, Timeslots::instance()->getObjectTypeId())) {
$tmp_users[] = $user;
}
}
$users = $tmp_users;
}
//Get Companies Info
if (logged_user()->isMemberOfOwnerCompany() || logged_user()->isAdminGroup()) {
$companies = Contacts::getCompaniesWithUsers();
} else {
$companies = array();
if (logged_user()->getCompanyId() > 0) {
$companies[] = logged_user()->getCompany();
}
}
$required_dimensions = DimensionObjectTypeContents::getRequiredDimensions(Timeslots::instance()->getObjectTypeId());
$draw_inputs = !$required_dimensions || count($required_dimensions) == 0;
if (!$draw_inputs) {
$ts_ots = DimensionObjectTypeContents::getDimensionObjectTypesforObject(Timeslots::instance()->getObjectTypeId());
$context = active_context();
foreach ($context as $sel) {
if ($sel instanceof Member) {
foreach ($ts_ots as $ts_ot) {
if ($sel->getDimensionId() == $ts_ot->getDimensionId() && $sel->getObjectTypeId() == $ts_ot->getDimensionObjectTypeId()) {
$draw_inputs = true;
break;
}
}
if ($draw_inputs) {
break;
}
}
}
//.........这里部分代码省略.........
示例6: updateBillingValues
static function updateBillingValues()
{
$timeslot_rows = DB::executeAll("SELECT * FROM " . TABLE_PREFIX . "timeslots WHERE `end_time` > 0 AND billing_id = 0 AND is_fixed_billing = 0");
$users = Contacts::getAllUsers();
$usArray = array();
foreach ($users as $u) {
$usArray[$u->getId()] = $u;
}
$count = 0;
$categories_cache = array();
foreach ($timeslot_rows as $ts_row) {
if ($ts_row['start_time'] == EMPTY_DATETIME) {
$ts_row['minutes'] = 0;
} else {
$startTime = DateTimeValueLib::makeFromString($ts_row['start_time']);
if ($ts_row['start_time'] == EMPTY_DATETIME) {
$endTime = $ts_row['is_paused'] ? DateTimeValueLib::makeFromString($ts_row['paused_on']) : DateTimeValueLib::now();
} else {
$endTime = DateTimeValueLib::makeFromString($ts_row['end_time']);
}
$timeDiff = DateTimeValueLib::get_time_difference($startTime->getTimestamp(), $endTime->getTimestamp(), $ts_row['subtract']);
$ts_row['minutes'] = $timeDiff['days'] * 1440 + $timeDiff['hours'] * 60 + $timeDiff['minutes'];
}
$user = $usArray[$ts_row['contact_id']];
if ($user instanceof Contact) {
$billing_category_id = $user->getDefaultBillingId();
if ($billing_category_id > 0) {
$hours = $ts_row['minutes'] / 60;
$billing_category = array_var($categories_cache, $billing_category_id);
if (!$billing_category instanceof BillingCategory) {
$billing_category = BillingCategories::findById($billing_category_id);
$categories_cache[$billing_category_id] = $billing_category;
}
if ($billing_category instanceof BillingCategory) {
$hourly_billing = $billing_category->getDefaultValue();
DB::execute("UPDATE " . TABLE_PREFIX . "timeslots SET billing_id='{$billing_category_id}', hourly_billing='{$hourly_billing}', \r\n\t\t\t\t\t\t\tfixed_billing='" . round($hourly_billing * $hours, 2) . "', is_fixed_billing=0 \r\n\t\t\t\t\t\t\tWHERE object_id=" . $ts_row['object_id']);
$count++;
}
}
} else {
DB::execute("UPDATE " . TABLE_PREFIX . "timeslots SET is_fixed_billing=1 WHERE object_id=" . $ts_row['object_id']);
}
}
return $count;
}
示例7: updateBillingValues
/**
* This function sets the selected billing values for all timeslots which lack any type of billing values (value set to 0).
* This function is used when users start to use billing in the system.
*
* @return unknown_type
*/
static function updateBillingValues()
{
$timeslots = Timeslots::findAll(array('conditions' => '`end_time` > 0 AND billing_id = 0 AND is_fixed_billing = 0', 'join' => array('table' => Objects::instance()->getTableName(true), 'jt_field' => 'id', 'e_field' => 'rel_object_id')));
$users = Contacts::getAllUsers();
$usArray = array();
foreach ($users as $u) {
$usArray[$u->getId()] = $u;
}
$pbidCache = array();
$count = 0;
$categories_cache = array();
foreach ($timeslots as $ts) {
/* @var $ts Timeslot */
$user = $usArray[$ts->getContactId()];
if ($user instanceof Contact) {
$billing_category_id = $user->getDefaultBillingId();
if ($billing_category_id > 0) {
$hours = $ts->getMinutes() / 60;
$billing_category = array_var($categories_cache, $billing_category_id);
if (!$billing_category instanceof BillingCategory) {
$billing_category = BillingCategories::findById($billing_category_id);
$categories_cache[$billing_category_id] = $billing_category;
}
if ($billing_category instanceof BillingCategory) {
$hourly_billing = $billing_category->getDefaultValue();
$ts->setBillingId($billing_category_id);
$ts->setHourlyBilling($hourly_billing);
$ts->setFixedBilling(round($hourly_billing * $hours, 2));
$ts->setIsFixedBilling(false);
$ts->save();
$count++;
}
}
} else {
$ts->setIsFixedBilling(true);
$ts->save();
}
}
return $count;
}
示例8: lang
echo lang('description');
?>
: </div>
<?php
echo textarea_field("timeslot[description]", array_var($timeslot_data, 'description'), array('class' => 'short', 'id' => 'addTimeslotDescription', 'tabindex' => '10'));
?>
</div>
<table style="margin-top:10px;">
<?php
if (can_manage_time(logged_user())) {
echo '<tr><td style="vertical-align:middle;"><span class="bold">' . lang("person") . ': </span></td>';
if (logged_user()->isMemberOfOwnerCompany()) {
$users = Contacts::getAllUsers();
} else {
$users = logged_user()->getCompanyId() > 0 ? Contacts::getAllUsers(" AND `company_id` = " . logged_user()->getCompanyId()) : array(logged_user());
}
$tmp_users = array();
foreach ($users as $user) {
$rel_object = $timeslot->getRelObject();
$is_assigned = $rel_object instanceof ProjectTask && $rel_object->getAssignedToContactId() == $user->getId();
if ($is_assigned || can_add($user, $rel_object->getMembers(), Timeslots::instance()->getObjectTypeId())) {
$tmp_users[] = $user;
}
}
$users = $tmp_users;
$user_options = array();
foreach ($users as $user) {
$user_options[] = option_tag($user->getObjectName(), $user->getId(), array_var($timeslot_data, 'contact_id') == $user->getId() ? array("selected" => "selected") : null);
}
echo '<td>' . select_box("timeslot[contact_id]", $user_options, array('id' => $genid . 'tsUser', 'tabindex' => '15')) . '</td></tr>';
示例9: getGroupedByCompany
/**
* Return contacts grouped by company
*
* @param void
* @return array
*/
static function getGroupedByCompany($include_disabled = true)
{
$companies = self::findAll(array('conditions' => array("`is_company` = 1")));
if (!is_array($companies) || !count($companies)) {
//return null;
}
$result = array();
$comp_ids = array(0);
foreach ($companies as $company) {
$comp_ids[] = $company->getId();
$result[$company->getId()] = array('details' => $company, 'users' => array());
}
$company_users = Contacts::findAll(array('order' => 'company_id, first_name, surname', 'conditions' => 'user_type<>0 AND company_id IN (' . implode(',', $comp_ids) . ')' . ($include_disabled ? "" : " AND disabled=0")));
foreach ($company_users as $user) {
$result[$user->getCompanyId()]['users'][] = $user;
}
$res = array();
foreach ($result as $comp_info) {
if (array_var($comp_info, 'details') instanceof Contact) {
$res[$comp_info['details']->getObjectName()] = $comp_info;
}
}
$result = $res;
$no_company_users = Contacts::getAllUsers("AND `company_id` = 0", $include_disabled);
if (count($no_company_users) > 0) {
$result[lang('without company')] = array('details' => null, 'users' => $no_company_users);
}
return count($result) ? $result : null;
}
示例10: 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);
}
示例11: add_account
/**
* Add email account
*
* @access public
* @param void
* @return null
*/
function add_account()
{
if (logged_user()->isGuest()) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
if (!MailAccount::canAdd(logged_user())) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
// if
$mailAccount = new MailAccount();
tpl_assign('mailAccount', $mailAccount);
$mailAccount_data = array_var($_POST, 'mailAccount');
tpl_assign('mailAccount_data', $mailAccount_data);
// get mail account users
$mau = array(logged_user()->getId() => array('name' => logged_user()->getObjectName(), 'can_edit' => true));
tpl_assign('mailAccountUsers', $mau);
$is_admin = logged_user()->isAdministrator();
tpl_assign('is_admin', $is_admin);
if (is_array(array_var($_POST, 'mailAccount'))) {
$email_address = array_var(array_var($_POST, 'mailAccount'), 'email_addr');
/*if (MailAccounts::findOne(array('conditions' => "`email` = '$email_address'")) != null) {
flash_error(lang('email address already exists'));
ajx_current("empty");
return;
}*/
try {
$selected_user = array_var($_POST, 'users_select_box');
if (!$is_admin) {
$mail_account_user = logged_user();
} else {
$mail_account_user = Contacts::findById($selected_user);
}
$mailAccount_data['sync_ssl'] = array_var($mailAccount_data, 'sync_ssl') == "checked";
$mailAccount_data['contact_id'] = $mail_account_user->getId();
if (!array_var($mailAccount_data, 'del_mails_from_server', false)) {
$mailAccount_data['del_from_server'] = 0;
}
if (!array_var($mailAccount_data, 'mark_read_on_server', false)) {
$mailAccount_data['mark_read_on_server'] = 0;
}
$mailAccount->setFromAttributes($mailAccount_data);
$mailAccount->setServer(trim($mailAccount->getServer()));
$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);
}
$member_ids = json_decode(array_var($_POST, 'members'));
$member_ids_str = "";
foreach ($member_ids as $mid) {
if (is_numeric($mid)) {
$member_ids_str .= ($member_ids_str == "" ? "" : ",") . $mid;
}
}
$mailAccount->setMemberId($member_ids_str);
DB::beginWork();
$mailAccount->save();
// process users
$account_users = Contacts::getAllUsers();
$user_access = array_var($_POST, 'user_access');
foreach ($account_users as $account_user) {
$user_id = $account_user->getId();
$access = array_var($user_access, $user_id);
if (!is_null($access) && $access != 'none' || $user_id == $mail_account_user->getId()) {
$account_user = new MailAccountContact();
$account_user->setAccountId($mailAccount->getId());
$account_user->setContactId($user_id);
$account_user->setCanEdit($access == 'write');
$account_user->save();
}
}
if ($mailAccount->getIsImap() && is_array(array_var($_POST, 'check'))) {
$real_folders = MailUtilities::getImapFolders($mailAccount);
foreach ($real_folders as $folder_name) {
if (!MailAccountImapFolders::findById(array('account_id' => $mailAccount->getId(), 'folder_name' => $folder_name))) {
$acc_folder = new MailAccountImapFolder();
$acc_folder->setAccountId($mailAccount->getId());
$acc_folder->setFolderName($folder_name);
$acc_folder->setCheckFolder($folder_name == 'INBOX');
// By default only INBOX is checked
$acc_folder->save();
}
}
$imap_folders = MailAccountImapFolders::getMailAccountImapFolders($mailAccount->getId());
$checks = array_var($_POST, 'check');
if (is_array($imap_folders) && count($imap_folders)) {
foreach ($imap_folders as $folder) {
//.........这里部分代码省略.........
示例12: getAllRoleUsers
function getAllRoleUsers($role)
{
$contacts = Contacts::getAllUsers(" AND `user_type` = {$role}");
$pgs = array();
if (!$contacts) {
return false;
}
foreach ($contacts as $contact) {
alert(" " . $contact->getObjectName());
$pgs[] = $contact->getPermissionGroupId();
}
return $pgs;
}
示例13: 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,
);
}
示例14: MAX
$max_depth = DB::executeOne("SELECT MAX(depth) AS depth FROM `" . TABLE_PREFIX . "members`");
//update all depths
for ($i = $depth; $i <= $max_depth['depth']; $i++) {
//update members depth
DB::execute("UPDATE " . TABLE_PREFIX . "members SET depth = " . $depth . " WHERE parent_member_id IN (" . $members_depth . ");");
//Get member from next depth
$members_depth = DB::executeAll("SELECT id FROM " . TABLE_PREFIX . "members WHERE depth= " . $depth . " ORDER BY id");
$members_depth = array_flat($members_depth);
$members_depth = implode(",", $members_depth);
$depth++;
}
//END UPDATE depth for all members
echo "\nStart Truncate contact_member_cache\n-----------------------------------------------------------------";
DB::execute("TRUNCATE TABLE " . TABLE_PREFIX . "contact_member_cache;");
echo "\nEnd Truncate contact_member_cache\n-----------------------------------------------------------------";
$users = Contacts::getAllUsers();
$dimensions = Dimensions::findAll();
$dimensions_ids = array();
foreach ($dimensions as $dimension) {
if ($dimension->getDefinesPermissions()) {
$dimensions_ids[] = $dimension->getId();
}
}
$dimensions_ids = implode(",", $dimensions_ids);
$root_members = DB::executeAll("SELECT * FROM " . TABLE_PREFIX . "members WHERE dimension_id IN (" . $dimensions_ids . ") AND parent_member_id=0 ORDER BY id");
foreach ($users as $user) {
echo "\n" . $user->getName();
try {
DB::beginWork();
foreach ($root_members as $member) {
ContactMemberCaches::updateContactMemberCache($user, $member['id'], $member['parent_member_id']);
示例15: 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);
}
}