/** * * @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()); } } }
/** * 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) { tpl_assign('error', $e); } } }
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(); $showDimensionCols = array_map('intval', explode(',', user_config_option('tasksShowDimensionCols'))); $userPref = array('filterValue' => isset($filter_value) ? $filter_value : '', 'filter' => $filter, 'dateStart' => $dateStart, 'dateEnd' => $dateEnd, 'status' => $status, 'showTime' => user_config_option('tasksShowTime'), 'showDates' => user_config_option('tasksShowDates'), 'showStartDates' => user_config_option('tasksShowStartDates'), 'showEndDates' => user_config_option('tasksShowEndDates'), 'showBy' => user_config_option('tasksShowAssignedBy'), 'showClassification' => user_config_option('tasksShowClassification'), 'showSubtasksStructure' => user_config_option('tasksShowSubtasksStructure'), 'showTags' => user_config_option('tasksShowTags', 0), 'showEmptyMilestones' => user_config_option('tasksShowEmptyMilestones', 1), 'showTimeEstimates' => user_config_option('tasksShowTimeEstimates', 1), 'showTimePending' => user_config_option('tasksShowTimePending', 1), 'showTimeWorked' => user_config_option('tasksShowTimeWorked', 1), 'showPercentCompletedBar' => user_config_option('tasksShowPercentCompletedBar', 1), 'showQuickEdit' => user_config_option('tasksShowQuickEdit', 1), 'showQuickComplete' => user_config_option('tasksShowQuickComplete', 1), 'showQuickComment' => user_config_option('tasksShowQuickComment', 1), 'showQuickAddSubTasks' => user_config_option('tasksShowQuickAddSubTasks', 1), 'showDimensionCols' => $showDimensionCols, 'groupBy' => user_config_option('tasksGroupBy'), 'orderBy' => user_config_option('tasksOrderBy'), 'previousPendingTasks' => user_config_option('tasksPreviousPendingTasks', 1), 'defaultNotifyValue' => user_config_option('can notify from quick add')); hook::fire('tasks_user_preferences', null, $userPref); tpl_assign('userPreferences', $userPref); tpl_assign('userPermissions', array('can_add' => ProjectTask::canAdd(logged_user(), active_context()) ? 1 : 0)); ajx_set_no_toolbar(true); } }
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; }
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; } } } } tpl_assign('draw_inputs', $draw_inputs); tpl_assign('selected_user', logged_user()->getId()); tpl_assign('timeslots', $timeslots); tpl_assign('tasks', $tasks); if (count($tasks) > 0) { tpl_assign('all_users', Contacts::getAllUsers()); } tpl_assign('users', $users); tpl_assign('start', $start); tpl_assign('limit', $limit); tpl_assign('total', $total); tpl_assign('companies', $companies); ajx_set_no_toolbar(true); }
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; }
/** * 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; }
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>';
/** * 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; }
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); }
/** * 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) { $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(); } } } // personal settings if (array_var($_POST, 'is_default')) { $user_accounts = MailAccountContacts::getByContact(logged_user()); foreach ($user_accounts as $acc) { if ($acc->getAccountId() != $mailAccount->getId()) { $acc->setIsDefault(false); $acc->save(); } else { $acc->setIsDefault(true); $acc->save(); } } } $logged_user_settings = MailAccountContacts::getByAccountAndContact($mailAccount, logged_user()); if ($logged_user_settings instanceof MailAccountContact) { $logged_user_settings->setSignature(array_var($_POST, 'signature')); $logged_user_settings->setSenderName(array_var($_POST, 'sender_name')); $logged_user_settings->save(); } if ($mailAccount->canView(logged_user())) { evt_add("mail account added", array("id" => $mailAccount->getId(), "name" => $mailAccount->getName(), "email" => $mailAccount->getEmail())); } // Restore old emails, if account was deleted and its emails weren't DB::executeAll("\r\n\t\t\t\t\t\tUPDATE " . TABLE_PREFIX . "mail_contents mc INNER JOIN " . TABLE_PREFIX . "objects o ON mc.object_id = o.id\r\n\t\t\t\t\t\t\tSET mc.account_id=" . $mailAccount->getId() . " \r\n\t\t\t\t\t\t\tWHERE o.`created_by_id` = " . $mail_account_user->getId() . " \r\n\t\t\t\t\t\t\t\t\tAND mc.`account_email` = '" . $mailAccount->getEmail() . "' \r\n\t\t\t\t\t\t\t\t\tAND mc.`account_id` NOT IN (SELECT `id` FROM `" . TABLE_PREFIX . "mail_accounts`)"); DB::commit(); flash_success(lang('success add mail account', $mailAccount->getName())); ajx_current("back"); // Error... } catch (Exception $e) { DB::rollback(); ajx_current("empty"); flash_error($e->getMessage()); } } }
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; }
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, ); }
$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']);
function new_list_tasks() { //load config options into cache for better performance load_user_config_options_by_category_name('task panel'); // get query parameters, save user preferences if necessary $status = array_var($_GET, 'status', null); if (is_null($status) || $status == '') { $status = user_config_option('task panel status', 2); } else { if (user_config_option('task panel status') != $status) { set_user_config_option('task panel status', $status, logged_user()->getId()); } } $previous_filter = user_config_option('task panel filter', 'no_filter'); $filter = array_var($_GET, 'filter'); if (is_null($filter) || $filter == '') { $filter = $previous_filter; } else { if ($previous_filter != $filter) { set_user_config_option('task panel filter', $filter, logged_user()->getId()); } } if ($filter != 'no_filter') { $filter_value = array_var($_GET, 'fval'); if (is_null($filter_value) || $filter_value == '') { $filter_value = user_config_option('task panel filter value', null, logged_user()->getId()); set_user_config_option('task panel filter value', $filter_value, logged_user()->getId()); $filter = $previous_filter; set_user_config_option('task panel filter', $filter, logged_user()->getId()); } else { if (user_config_option('task panel filter value') != $filter_value) { set_user_config_option('task panel filter value', $filter_value, logged_user()->getId()); } } } $isJson = array_var($_GET, 'isJson', false); if ($isJson) { ajx_current("empty"); } $template_condition = "`is_template` = 0 "; //Get the task query conditions $task_filter_condition = ""; switch ($filter) { case 'assigned_to': $assigned_to = $filter_value; if ($assigned_to > 0) { $task_filter_condition = " AND (`assigned_to_contact_id` = " . $assigned_to . ") "; } else { if ($assigned_to == -1) { $task_filter_condition = " AND `assigned_to_contact_id` = 0"; } } break; case 'assigned_by': if ($filter_value != 0) { $task_filter_condition = " AND `assigned_by_id` = " . $filter_value . " "; } break; case 'created_by': if ($filter_value != 0) { $task_filter_condition = " AND `created_by_id` = " . $filter_value . " "; } break; case 'completed_by': if ($filter_value != 0) { $task_filter_condition = " AND `completed_by_id` = " . $filter_value . " "; } break; case 'milestone': $task_filter_condition = " AND `milestone_id` = " . $filter_value . " "; break; case 'priority': $task_filter_condition = " AND `priority` = " . $filter_value . " "; break; case 'subtype': if ($filter_value != 0) { $task_filter_condition = " AND `object_subtype` = " . $filter_value . " "; } break; case 'no_filter': $task_filter_condition = ""; break; default: flash_error(lang('task filter criteria not recognised', $filter)); } $task_status_condition = ""; $now = DateTimeValueLib::now()->format('Y-m-j 00:00:00'); switch ($status) { case 0: // Incomplete tasks $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME); break; case 1: // Complete tasks $task_status_condition = " AND `completed_on` > " . DB::escape(EMPTY_DATETIME); break; case 10: // Active tasks $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `start_date` <= '{$now}'"; break; case 11: // Overdue tasks $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `due_date` < '{$now}'"; break; case 12: // Today tasks $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `due_date` = '{$now}'"; break; case 13: // Today + Overdue tasks $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `due_date` <= '{$now}'"; break; case 14: // Today + Overdue 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); } }
function getAllRoleUsers($role){ $contacts=Contacts::getAllUsers(" AND `user_type` = $role"); $pgs=array(); if(!$contacts)return false; foreach ($contacts as $contact){ $pgs[]=$contact->getPermissionGroupId(); } return $pgs; }
function core_dimensions_update_9_10() { $template_ot = ObjectTypes::findByName('template'); $users = Contacts::getAllUsers(); foreach ($users as $user) { /* @var $user Contact */ if (!$user->isAdminGroup()) { continue; } // don't allow to write emails for collaborators and guests $user_type_name = $user->getUserTypeName(); if ($template_ot instanceof ObjectType) { DB::executeAll("UPDATE " . TABLE_PREFIX . "contact_member_permissions SET can_write=1, can_delete=1 WHERE object_type_id=" . $template_ot->getId() . " AND permission_group_id=" . $user->getPermissionGroupId()); } } $pgs = PermissionGroups::findAll(array("conditions" => "`name` in ('Super Administrator','Administrator')")); foreach ($pgs as $pg) { DB::executeAll("UPDATE " . TABLE_PREFIX . "role_object_type_permissions SET can_write=1, can_delete=1 WHERE object_type_id=" . $template_ot->getId() . " AND role_id=" . $user->getPermissionGroupId()); } }
$tabs_allowed = TabPanelPermissions::getAllRolesModules(); echo "og.tabs_allowed=" . json_encode($tabs_allowed) . ";"; $guest_groups = PermissionGroups::instance()->getGuestPermissionGroups(); echo "og.guest_permission_group_ids = [];"; foreach ($guest_groups as $gg) { echo "og.guest_permission_group_ids.push(" . $gg->getId() . ");"; } $executive_groups = PermissionGroups::instance()->getExecutivePermissionGroups(); echo "og.executive_permission_group_ids = [];"; foreach ($executive_groups as $eg) { echo "og.executive_permission_group_ids.push(" . $eg->getId() . ");"; } ?> <?php $allUsers = Contacts::getAllUsers(null, true); foreach ($allUsers as $usr) { $usr_info = $usr->getArrayInfo(); $allUsers_array[$usr->getId()] = $usr_info; } ?> og.allUsers = <?php echo clean(str_replace('"', "'", escape_character(json_encode($allUsers_array)))); ?> ; <?php $object_types = ObjectTypes::getAllObjectTypes(); foreach ($object_types as $ot) { $types[$ot->getId()] = array("name" => $ot->getName(), "icon" => $ot->getIconClass(), "type" => $ot->getType()); }