function get_custom_properties() { $object_type = array_var($_GET, 'object_type'); if ($object_type) { $cp = CustomProperties::getAllCustomPropertiesByObjectType($object_type); $customProperties = array(); foreach ($cp as $custom) { $prop = array(); $prop['id'] = $custom->getId(); $prop['name'] = $custom->getName(); $prop['object_type'] = $custom->getObjectTypeId(); $prop['description'] = $custom->getDescription(); $prop['type'] = $custom->getType(); $prop['values'] = $custom->getValues(); $prop['default_value'] = $custom->getDefaultValue(); $prop['required'] = $custom->getIsRequired(); $prop['multiple_values'] = $custom->getIsMultipleValues(); $prop['visible_by_default'] = $custom->getVisibleByDefault(); $prop['co_types'] = ''; //CustomPropertiesByCoType::instance()->getCoTypesIdsForCpCSV($custom->getId()); $customProperties[] = $prop; } ajx_current("empty"); ajx_extra_data(array("custom_properties" => $customProperties)); } }
function get_help_content() { if (!array_var($_GET, 'template')) { return; } $template = array_var($_GET, 'template'); ajx_current("empty"); ajx_extra_data(array("content" => load_help($template), "is_help_data" => 1)); }
function get_assignable_parents() { if (!can_manage_dimension_members(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } $dim_id = get_id('dim'); $otype_id = get_id('otype'); $parents_info = self::getAssignableParents($dim_id, $otype_id); ajx_extra_data(array("parents" => $parents_info)); ajx_current("empty"); }
function initial_list_projects() { ajx_current("empty"); $parent = 0; $all_ws = logged_user()->getWorkspaces(true); if (!is_array($all_ws)) { $all_ws = array(); } $wsset = array(); foreach ($all_ws as $w) { $wsset[$w->getId()] = true; } $ws = array(); foreach ($all_ws as $w) { $tempParent = $w->getParentId(); $x = $w; while ($x instanceof Project && !isset($wsset[$tempParent])) { $tempParent = $x->getParentId(); $x = $x->getParentWorkspace(); } if (!$x instanceof Project) { $tempParent = 0; } $workspace = array("id" => $w->getId(), "name" => $w->getName(), "color" => $w->getColor(), "parent" => $tempParent, "realParent" => $w->getParentId(), "depth" => $w->getDepth()); if (logged_user()->getPersonalProjectId() == $w->getId()) { $workspace["isPersonal"] = true; } $ws[] = $workspace; } ajx_extra_data(array('workspaces' => $ws)); }
function get_external_field_values() { $field = array_var($_GET, 'external_field'); $report_type = array_var($_GET, 'report_type'); $values = $this->get_ext_values($field, $report_type); ajx_current("empty"); ajx_extra_data(array('values' => $values)); }
function get_user_preference() { ajx_current("empty"); $option_name = array_var($_REQUEST, 'name'); $option_value = ""; if ($option_name != '') { $option_value = user_config_option($option_name); } ajx_extra_data(array('opt_val' => $option_value)); }
function search_permission_group() { $name = trim(array_var($_REQUEST, 'query', '')); $start = array_var($_REQUEST, 'start', 0); $orig_limit = array_var($_REQUEST, 'limit'); $limit = $orig_limit + 1; $query_name = ""; if (strlen($name) > 0) { $query_name = "AND (c.first_name LIKE '%{$name}%' OR c.surname LIKE '%{$name}%' OR pg.name LIKE '%{$name}%')"; } // query for permission groups $sql = "SELECT * FROM " . TABLE_PREFIX . "permission_groups pg LEFT JOIN " . TABLE_PREFIX . "contacts c ON pg.id=c.permission_group_id\r\n\t\t\tWHERE pg.type IN ('permission_groups', 'user_groups') AND (c.user_type IS NULL OR c.user_type >= " . logged_user()->getUserType() . ") {$query_name}\r\n\t\t\tORDER BY c.first_name, c.surname, pg.name\r\n\t\t\tLIMIT {$start}, {$limit}"; $rows = DB::executeAll($sql); if (!is_array($rows)) { $rows = array(); } // show more $show_more = false; if (count($rows) > $orig_limit) { array_pop($rows); $show_more = true; } if ($show_more) { ajx_extra_data(array('show_more' => $show_more)); } $tmp_companies = array(); $tmp_roles = array(); $permission_groups = array(); foreach ($rows as $pg_data) { // basic data $data = array('pg_id' => $pg_data['id'], 'type' => $pg_data['type'] == 'permission_groups' ? 'user' : 'group', 'iconCls' => '', 'name' => is_null($pg_data['first_name']) && is_null($pg_data['surname']) ? $pg_data['name'] : trim($pg_data['first_name'] . ' ' . $pg_data['surname'])); // company name $comp_id = array_var($pg_data, 'company_id'); if ($comp_id > 0) { if (!isset($tmp_companies[$comp_id])) { $tmp_companies[$comp_id] = Contacts::findById($comp_id); } $c = array_var($tmp_companies, $comp_id); if ($c instanceof Contact) { $data['company_name'] = trim($c->getObjectName()); } } // picture if ($pg_data['type'] == 'permission_groups') { $data['user_id'] = array_var($pg_data, 'object_id'); if (array_var($pg_data, 'picture_file') != '') { $data['picture_url'] = get_url('files', 'get_public_file', array('id' => array_var($pg_data, 'picture_file'))); } } // user type $user_type_id = array_var($pg_data, 'user_type'); if ($user_type_id > 0) { if (!isset($tmp_roles[$user_type_id])) { $tmp_roles[$user_type_id] = PermissionGroups::findById($user_type_id); } $rol = array_var($tmp_roles, $user_type_id); if ($rol instanceof PermissionGroup) { $data['role'] = trim($rol->getName()); if (in_array($rol->getName(), array('Guest', 'Guest Customer'))) { $data['is_guest'] = '1'; } } } $permission_groups[] = $data; } $row = "search-result-row-medium"; ajx_extra_data(array('row_class' => $row)); ajx_extra_data(array('permission_groups' => $permission_groups)); ajx_current("empty"); }
/** * View single message * * @access public * @param void * @return null */ function view() { $this->addHelper('textile'); $message = ProjectMessages::findById(get_id()); if (!$message instanceof ProjectMessage) { flash_error(lang('message dnx')); ajx_current("empty"); return; } // if if (!$message->canView(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } // if $this->setHelp("view_message"); //read object for this user $message->setIsRead(logged_user()->getId(), true); tpl_assign('message', $message); tpl_assign('subscribers', $message->getSubscribers()); ajx_extra_data(array("title" => $message->getTitle(), 'icon' => $message->getIconClass())); ajx_set_no_toolbar(true); ApplicationReadLogs::createLog($message, ApplicationReadLogs::ACTION_READ); }
/** * List all tags * */ function list_tags() { ajx_current("empty"); $order = array_var($_GET, 'order', 'count'); $ts = array(); $tags = Tags::getTagNames($order); $extra = array(); $extra['tags'] = $tags; ajx_extra_data($extra); }
function get_cusotm_property_columns() { $grouped = array(); $cp_rows = DB::executeAll("SELECT cp.id, cp.name as cp_name, ot.name as obj_type FROM ".TABLE_PREFIX."custom_properties cp INNER JOIN ".TABLE_PREFIX."object_types ot on ot.id=cp.object_type_id ORDER BY ot.name"); if (is_array($cp_rows)) { foreach ($cp_rows as $row) { if (!isset($grouped[$row['obj_type']])) $grouped[$row['obj_type']] = array(); $grouped[$row['obj_type']][] = array('id' => $row['id'], 'name' => $row['cp_name']); } } ajx_current("empty"); ajx_extra_data(array('properties' => $grouped)); }
function get_template_tasks_data() { ajx_current("empty"); $ids = explode(',', array_var($_REQUEST, 'ids')); foreach ($ids as $k => &$id) { if (!is_numeric($id)) { unset($ids[$k]); } } $objects = array(); if (count($ids) > 0) { $tasks = TemplateTasks::findAll(array('conditions' => 'id IN (' . implode(',', $ids) . ')')); $ot = ObjectTypes::findByName('template_task'); foreach ($tasks as $task) { $objects[] = $this->prepareObject($task->getId(), $task->getId(), $task->getObjectName(), $ot->getName(), $task->manager(), "", $task->getMilestoneId(), array(), $task->getParentId(), 'ico-task'); } } ajx_extra_data(array('tasks' => $objects)); }
function delete_project_timeslot() { if (!can_manage_time(logged_user(), true)) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } ajx_current("empty"); $timeslot = Timeslots::findById(get_id()); if (!$timeslot instanceof Timeslot) { flash_error(lang('timeslot dnx')); return; } if (!$timeslot->canDelete(logged_user())) { flash_error(lang('no access permissions')); return; } try { DB::beginWork(); $timeslot->delete(); DB::commit(); ajx_extra_data(array("timeslotId" => get_id())); } catch (Exception $e) { DB::rollback(); flash_error($e->getMessage()); } // try }
/** * Returns the milestones included in the present workspace and all of its parents. This is because tasks from a particular workspace * can only be assigned to milestones from that workspace and from any of its parents. */ function get_assignable_milestones() { ajx_current("empty"); $ms = ProjectMilestones::findAll(); if ($ms === null) $ms = array(); $ms_info = array(); foreach ($ms as $milestone) { $ms_info[] = $milestone->getArrayInfo(); } ajx_extra_data(array('milestones' => $ms_info)); }
/** * Edit specific message * * @access public * @param void * @return null */ function edit() { $this->setTemplate('add_message'); if (logged_user()->isGuest()) { flash_error(lang('no access permissions')); ajx_current('empty'); return; } $message = ProjectMessages::findById(get_id()); if (!$message instanceof ProjectMessage) { flash_error(lang('message dnx')); ajx_current("empty"); return; } // if if (!$message->canEdit(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } // if $message_data = array_var($_POST, 'message'); if (!is_array($message_data)) { $tag_names = $message->getTagNames(); $message_data = array('milestone_id' => $message->getMilestoneId(), 'title' => $message->getTitle(), 'text' => $message->getText(), 'additional_text' => $message->getAdditionalText(), 'tags' => is_array($tag_names) ? implode(', ', $tag_names) : '', 'is_private' => $message->isPrivate(), 'is_important' => $message->getIsImportant(), 'comments_enabled' => $message->getCommentsEnabled(), 'anonymous_comments_enabled' => $message->getAnonymousCommentsEnabled()); // array } // if tpl_assign('message', $message); tpl_assign('message_data', $message_data); if (is_array(array_var($_POST, 'message'))) { try { //MANAGE CONCURRENCE WHILE EDITING $upd = array_var($_POST, 'updatedon'); if ($upd && $message->getUpdatedOn()->getTimestamp() > $upd && !array_var($_POST, 'merge-changes') == 'true') { ajx_current('empty'); evt_add("handle edit concurrence", array("updatedon" => $message->getUpdatedOn()->getTimestamp(), "genid" => array_var($_POST, 'genid'))); return; } if (array_var($_POST, 'merge-changes') == 'true') { $this->setTemplate('view'); $edited_note = ProjectMessages::findById($message->getId()); tpl_assign('message', $edited_note); tpl_assign('subscribers', $edited_note->getSubscribers()); ajx_extra_data(array("title" => $edited_note->getTitle(), 'icon' => 'ico-message')); ajx_set_no_toolbar(true); ajx_set_panel(lang('tab name', array('name' => $edited_note->getTitle()))); return; } $old_is_private = $message->isPrivate(); $old_is_important = $message->getIsImportant(); $old_comments_enabled = $message->getCommentsEnabled(); $old_anonymous_comments_enabled = $message->getAnonymousCommentsEnabled(); $message->setFromAttributes($message_data); // Options are reserved only for members of owner company if (!logged_user()->isMemberOfOwnerCompany()) { $message->setIsPrivate($old_is_private); $message->setIsImportant($old_is_important); $message->setCommentsEnabled($old_comments_enabled); $message->setAnonymousCommentsEnabled($old_anonymous_comments_enabled); } // if DB::beginWork(); $message->save(); $message->setTagsFromCSV(array_var($message_data, 'tags')); $object_controller = new ObjectController(); $object_controller->add_to_workspaces($message); $object_controller->link_to_new_object($message); $object_controller->add_subscribers($message); $object_controller->add_custom_properties($message); $message->resetIsRead(); ApplicationLogs::createLog($message, $message->getWorkspaces(), ApplicationLogs::ACTION_EDIT); DB::commit(); flash_success(lang('success edit message', $message->getTitle())); if (array_var($_POST, 'popup', false)) { ajx_current("reload"); } else { ajx_current("back"); } } catch (Exception $e) { DB::rollback(); flash_error($e->getMessage()); ajx_current("empty"); } // try } // if }
function initial_list_dimension_members_tree() { $dimension_id = array_var($_REQUEST, 'dimension_id'); $checkedField = (array_var($_REQUEST, 'checkboxes'))?"checked":"_checked"; $objectTypeId = array_var($_REQUEST, 'object_type_id', null ); $allowedMemberTypes = json_decode(array_var($_REQUEST, 'allowedMemberTypes', null )); if (!is_array($allowedMemberTypes)) { $allowedMemberTypes = null; } $only_names = array_var($_REQUEST, 'onlyname', false); $name = trim(array_var($_REQUEST, 'query', '')); $extra_cond = $name == "" ? "" : " AND name LIKE '".$name."%'"; $selected_member_ids = json_decode(array_var($_REQUEST, 'selected_ids', "[0]")); $selected_members = Members::findAll(array('conditions' => 'id IN ('.implode(',',$selected_member_ids).')')); $memberList = $this->initial_list_dimension_members($dimension_id, $objectTypeId, $allowedMemberTypes, false, $extra_cond, null, false, null, $only_names, $selected_members); $tree = buildTree($memberList, "parent", "children", "id", "name", $checkedField); ajx_current("empty"); ajx_extra_data(array('dimension_members' => $tree, 'dimension_id' => $dimension_id)); }
/** * Loads the logged user's mp3 files * */ function get_mp3() { ajx_current("empty"); /* get arguments */ $project = active_project(); $tag = array_var($_GET, 'tag'); $type = 'audio/mpeg'; /* query */ $files = ProjectFiles::getUserFiles(logged_user(), $project, $tag, $type, ProjectFiles::ORDER_BY_NAME, 'ASC'); if (!is_array($files)) { $files = array(); } /* prepare response object */ $mp3 = array('mp3' => array()); foreach ($files as $f) { $songname = $f->getProperty("songname"); $artist = $f->getProperty("songartist"); $album = $f->getProperty("songalbum"); $track = $f->getProperty("songtrack"); $year = $f->getProperty("songyear"); $duration = $f->getProperty("songduration"); $mp3["mp3"][] = array($songname, $artist, $album, $track, $year, $duration, $f->getDownloadUrl(), $f->getFilename(), $f->getId()); } ajx_extra_data($mp3); }
function copy() { if (logged_user()->isGuest()) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } ajx_set_no_toolbar(); $id = get_id(); $file = ProjectFiles::findById($id); if (!$file instanceof ProjectFile) { flash_error("file dnx"); ajx_current("empty"); return; } if (!$file->canView(logged_user())) { flash_error(lang("no access permissions")); ajx_current("empty"); return; } $original_members = $file->getMembers(); $members = $file->getAllowedMembersToAdd(logged_user(), $original_members); if (!$file->canAdd(logged_user(), $members, $notAllowedMember) ){ if (str_starts_with($notAllowedMember, '-- req dim --')) flash_error(lang('must choose at least one member of', str_replace_first('-- req dim --', '', $notAllowedMember, $in))); else flash_error(lang('no context permissions to add',lang("files"), $notAllowedMember)); ajx_current("empty"); return; } try { DB::beginWork(); $copy = $file->copy(); $copy->setFilename(lang('copy of file', $file->getFilename())); $copy->save(); $copy->addToMembers($members); $copy->addToSharingTable(); $rev_data = array(); $rev_data['name'] = $copy->getFilename(); $rev_data['size'] = $file->getFileSize(); $rev_data['type'] = $file->getTypeString(); $rev_data['tmp_name'] = ROOT . '/tmp/' . rand () ; $handler = fopen($rev_data['tmp_name'], 'w'); $file_content = $file->getLastRevision()->getFileContent(); fputs($handler, $file_content); fclose($handler); $copy->handleUploadedFile($rev_data, false, lang("copied from file", $file->getFilename(), $file->getUniqueObjectId())); DB::commit(); $this->setTemplate('file_details'); tpl_assign('file', $copy); tpl_assign('last_revision', $copy->getLastRevision()); tpl_assign('revisions', $copy->getRevisions()); tpl_assign('order', null); tpl_assign('page', null); ajx_extra_data(array("title" => $copy->getFilename(), 'icon'=>'ico-file')); ajx_set_no_toolbar(true); //read object for this user $copy->setIsRead(logged_user()->getId(),true); ApplicationReadLogs::createLog($copy, ApplicationReadLogs::ACTION_READ); } catch (Exception $ex) { DB::rollback(); flash_error($ex->getMessage()); ajx_current("empty"); } }
function update_dimension_order() { ajx_current("empty"); if (!can_manage_configuration(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } $dim_list = json_decode(array_var($_REQUEST, 'dims'), true); try { if (is_array($dim_list)) { DB::beginWork(); $pos = 1; foreach ($dim_list as $dim_id) { $dim_id = str_replace("'", "", $dim_id); DB::execute("UPDATE " . TABLE_PREFIX . "dimensions SET default_order={$pos} WHERE id='{$dim_id}'"); $pos++; } DB::commit(); } ajx_extra_data(array('ok' => '1', 'msg' => lang('success reordering dimensions'))); } catch (Exception $e) { DB::rollback(); ajx_extra_data(array('error' => 'Error occurred while reordering dimensions: ' . $e->getMessage())); } }
function re_render_custom_properties() { $object = Objects::findObject(array_var($_GET, 'id')); if (!$object) { // if id == 0 object is new, then a dummy object is created to render the properties. $object = new ProjectMessage(); } $html = render_object_custom_properties($object, array_var($_GET, 'req'), array_var($_GET, 'co_type')); $scripts = array(); $initag = "<script>"; $endtag = "</script>"; $pos = strpos($html, $initag); while ($pos !== FALSE) { $end_pos = strpos($html, $endtag, $pos); if ($end_pos === FALSE) { break; } $ini = $pos + strlen($initag); $sc = substr($html, $ini, $end_pos - $ini); if (!str_starts_with(trim($sc), "og.addTableCustomPropertyRow")) { // do not add repeated functions $scripts[] = $sc; } $pos = strpos($html, $initag, $end_pos); } foreach ($scripts as $sc) { $html = str_replace("{$initag}{$sc}{$endtag}", "", $html); } ajx_current("empty"); ajx_extra_data(array("html" => $html, 'scripts' => implode("", $scripts))); }
function list_all() { ajx_current ( "empty" ); ajx_extra_data ( array ("panels" => $this->loadPanels ( 'all' ) ) ); }
function view() { $this->addHelper("textile"); $weblink = ProjectWebpages::findById(get_id()); if (!$weblink instanceof ProjectWebpage) { flash_error(lang('weblink dnx')); ajx_current("empty"); return; } if (!$weblink->canView(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } $weblink->setIsRead(logged_user()->getId(), true); tpl_assign('object', $weblink); ajx_extra_data(array("title" => $weblink->getObjectName(), 'icon' => 'ico-weblink')); ajx_set_no_toolbar(true); ApplicationReadLogs::createLog($weblink, ApplicationReadLogs::ACTION_READ); }
function allowed_users_to_assign() { $wspace_id = array_var($_GET, "ws_id"); $comp_array = allowed_users_to_assign($wspace_id); $object = array("totalCount" => count($comp_array), "start" => 0, "companies" => array()); $object['companies'] = $comp_array; ajx_extra_data($object); ajx_current("empty"); }
function get_rendered_member_selectors() { $object_members = array(); $objectId = 0; if (get_id()) { $object = Objects::findObject(get_id()); $object_type_id = $object->manager()->getObjectTypeId(); $object_members = $object->getMemberIds(); $objectId = get_id(); } else { $object_type_id = array_var($_GET, 'objtypeid'); if (array_var($_GET, 'members')) { $object_members = explode(',', array_var($_GET, 'members')); } } if (count($object_members) == 0) { $object_members = active_context_members(false); } $genid = array_var($_GET, 'genid'); $listeners = array(); //ob_start — Turn on output buffering //no output is sent from the script (other than headers), instead the output is stored in an internal buffer. ob_start(); //get skipped dimensions for this view $view_name = array_var($_GET, 'view_name'); $dimensions_to_show = explode(",", user_config_option($view_name . "_view_dimensions_combos")); $dimensions_to_skip = array_diff(get_user_dimensions_ids(), $dimensions_to_show); render_member_selectors($object_type_id, $genid, $object_members, array('listeners' => $listeners), $dimensions_to_skip, null, false); ajx_current("empty"); //Gets the current buffer contents and delete current output buffer. //ob_get_clean() essentially executes both ob_get_contents() and ob_end_clean(). ajx_extra_data(array("htmlToAdd" => ob_get_clean())); ajx_extra_data(array("objectId" => $objectId)); }
/** * Returns the milestones included in the present workspace and all of its parents. This is because tasks from a particular workspace * can only be assigned to milestones from that workspace and from any of its parents. */ function get_workspace_milestones() { ajx_current("empty"); $ws_id = array_var($_GET, 'ws_id'); $workspace = Projects::findById($ws_id); if ($workspace instanceof Project) { $milestones = $workspace->getOpenMilestones(); $ms = array(); foreach ($milestones as $milestone) { $ms[] = array('id' => $milestone->getId(), 'name' => $milestone->getName()); } ajx_extra_data(array('milestones' => $ms)); } else { ajx_extra_data(array('milestones' => array())); } }
function check_related_task() { ajx_current("empty"); //I find all those related to the task to find out if the original $task_related = ProjectTasks::findByRelated(array_var($_REQUEST, 'related_id')); if (!$task_related) { $task_related = ProjectTasks::findById(array_var($_REQUEST, 'related_id')); //is not the original as the original look plus other related if ($task_related->getOriginalTaskId() != "0") { ajx_extra_data(array("status" => true)); } else { ajx_extra_data(array("status" => false)); } } else { ajx_extra_data(array("status" => true)); } }
function install($id = null){ ajx_current("empty"); $from_post = false; if (empty($id)){ $id = array_var($_POST, 'id'); $from_post = true; } if ($plg = Plugins::instance()->findById($id)) { $name = $plg->getName(); try { $this->executeInstaller($name); $plg->setIsInstalled(1); $plg->save(); } catch (Exception $e) { if ($from_post) { ajx_extra_data(array('errorMessage' => "Error installing plugin '$name': " . $e->getMessage())); } else { throw new Error("Error installing plugin '$name': " . $e->getMessage()); } } } }
function dimension_tree_for_permissions() { $dimension_id = array_var($_REQUEST, 'dimension_id'); $checkedField = array_var($_REQUEST, 'checkboxes') ? "checked" : "_checked"; $objectTypeId = array_var($_REQUEST, 'object_type_id', null); $allowedMemberTypes = json_decode(array_var($_REQUEST, 'allowedMemberTypes', null)); if (!is_array($allowedMemberTypes)) { $allowedMemberTypes = null; } $only_names = array_var($_REQUEST, 'onlyname', false); $name = trim(array_var($_REQUEST, 'query', '')); $extra_cond = $name == "" ? "" : " AND name LIKE '%" . $name . "%'"; if (array_var($_REQUEST, 'new_user')) { if (isset($_REQUEST['forced_members'])) { $forced_members = json_decode(array_var($_REQUEST, 'forced_members', '')); $fms = array(0); if (is_array($forced_members) && count($forced_members) > 0) { foreach ($forced_members as $fm) { if (is_numeric($fm)) { $fms[] = $fm; } } } if (count($fms) > 0) { $extra_cond .= " AND id IN (" . implode(',', $fms) . ")"; } } if (isset($_REQUEST['excluded_members'])) { $excluded_members = json_decode(array_var($_REQUEST, 'excluded_members', '')); $ems = array(0); if (is_array($excluded_members) && count($excluded_members) > 0) { foreach ($excluded_members as $em) { if (is_numeric($em)) { $ems[] = $em; } } } if (count($ems) > 0) { $extra_cond .= " AND id NOT IN (" . implode(',', $ems) . ")"; } } } else { // only use available object types $ots = ObjectTypes::getAvailableObjectTypes(); $available_ots_csv = ""; foreach ($ots as $ot) { $available_ots_csv .= ($available_ots_csv == "" ? "" : ",") . $ot->getId(); } if (trim($available_ots_csv) != "") { $ot_cond = " AND cmp.object_type_id IN ({$available_ots_csv})"; } else { $ot_cond = ""; } if (array_var($_REQUEST, 'only_with_perm')) { $extra_cond .= " AND EXISTS (SELECT cmp.member_id FROM " . TABLE_PREFIX . "contact_member_permissions cmp WHERE cmp.member_id=id AND cmp.permission_group_id=" . array_var($_REQUEST, 'pg', '-1') . " {$ot_cond})"; } else { if (array_var($_REQUEST, 'only_without_perm')) { $extra_cond .= " AND NOT EXISTS (SELECT cmp.member_id FROM " . TABLE_PREFIX . "contact_member_permissions cmp WHERE cmp.member_id=id AND cmp.permission_group_id=" . array_var($_REQUEST, 'pg', '-1') . " {$ot_cond})"; } } } $return_all_members = false; $selected_member_ids = json_decode(array_var($_REQUEST, 'selected_ids', "[0]")); $selected_members = Members::findAll(array('conditions' => 'id IN (' . implode(',', $selected_member_ids) . ')')); $memberList = $this->initial_list_dimension_members($dimension_id, $objectTypeId, $allowedMemberTypes, $return_all_members, $extra_cond, null, false, null, $only_names, $selected_members); // add missing parents $missing_parent_ids = array(); $all_members = array(); foreach ($memberList as $m) { $all_members[$m['id']] = $m['id']; } foreach ($memberList as $m) { if ($m['parent'] > 0 && !isset($all_members[$m['parent']])) { $missing_parent_ids[$m['parent']] = $m['parent']; } } while (count($missing_parent_ids) > 0) { $missing_members = DB::executeAll("SELECT m.*, ot.icon FROM " . TABLE_PREFIX . "members m INNER JOIN " . TABLE_PREFIX . "object_types ot ON ot.id=m.object_type_id WHERE m.id IN (" . implode(',', $missing_parent_ids) . ")"); $missing_parent_ids = array(); $new_missing = array(); foreach ($missing_members as $mem) { $m = array("id" => $mem['id'], "name" => clean($mem['name']), "parent" => $mem['parent_member_id'], "realParent" => $mem['parent_member_id'], "object_id" => $mem['object_id'], "depth" => $mem['depth'], "iconCls" => 'ico-' . $mem['icon'], "dimension_id" => $mem['dimension_id'], "object_type_id" => $mem['object_type_id'], "expandable" => true); $memberList[str_pad(array_var($m, 'parent'), 20, "0", STR_PAD_LEFT) . strtolower(array_var($m, 'name')) . array_var($m, 'id')] = $m; $new_missing[] = $m; $all_members[$m['id']] = $m; } foreach ($new_missing as $m) { if ($m['parent'] > 0 && !isset($all_members[$m['parent']])) { $missing_parent_ids[$m['parent']] = $m['parent']; } } } // -- $tree = buildTree($memberList, "parent", "children", "id", "name", $checkedField); ajx_current("empty"); ajx_extra_data(array('dimension_members' => $tree, 'dimension_id' => $dimension_id)); }
function get_object_properties() { $props = array(); $type = "ProjectTasks"; eval('$objectProperties = ' . $type . '::getTemplateObjectProperties();'); foreach ($objectProperties as $property) { $props[] = array('id' => $property['id'], 'name' => lang('field ' . $type . ' ' . $property['id']), 'type' => $property['type']); } ajx_current("empty"); ajx_extra_data(array('properties' => $props)); }
function get_company_data(){ ajx_current("empty"); $id = array_var($_GET, 'id'); $company = Contacts::findById($id); if ($company){ $address = $company->getAddress('work'); $street = ""; $city = ""; $state = ""; $zipcode = ""; $country = ""; if($address){ $street = $address->getStreet(); $city = $address->getCity(); $state = $address->getState(); $zipcode = $address->getZipCode(); $country = $address->getCountry(); } ajx_extra_data(array( "id" => $company->getObjectId(), "address" => $street, "state" => $state, "city" => $city, "country" => $country, "zipcode" => $zipcode, "webpage" => $company->getWebpageURL('work'), "phoneNumber" => $company->getPhoneNumber('work', true), "faxNumber" => $company->getPhoneNumber('fax', true) )); } else { ajx_extra_data(array( "id" => 0 )); } }
function get_unread_count() { ajx_current("empty"); ajx_extra_data(array('unreadCount' => MailContents::countUserInboxUnreadEmails())); }