コード例 #1
0
 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));
     }
 }
コード例 #2
0
 function add()
 {
     $pt = DB::escape(array_var($_GET, 'pt'));
     $t = DB::escape(array_var($_GET, 't'));
     $dep = ProjectTaskDependencies::findOne(array('conditions' => "`previous_task_id` = {$pt} AND `task_id` = {$t}"));
     if (!$dep instanceof ProjectTaskDependency) {
         try {
             DB::beginWork();
             $dep = new ProjectTaskDependency();
             $dep->setPreviousTaskId(array_var($_GET, 'pt'));
             $dep->setTaskId(array_var($_GET, 't'));
             $dep->save();
             DB::commit();
         } catch (Exception $e) {
             flash_error($e->getMessage());
             DB::rollback();
         }
     }
     flash_success(lang('success add task dependency'));
     $reload = array_var($_GET, 'reload', true);
     if ($reload) {
         ajx_current("reload");
     } else {
         ajx_current("empty");
     }
 }
コード例 #3
0
 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));
 }
コード例 #4
0
	function delete_state() {
		$this->setTemplate(get_template_path('back'));
		ajx_current("empty");
		try {
			$query = "DELETE FROM `" . TABLE_PREFIX . "guistate` WHERE `contact_id` = " . DB::escape(logged_user()->getId());
			DB::executeAll($query);
			flash_success(lang("success reset gui state"));
		} catch (Exception $e) {
			flash_error($e->getMessage());
		}
	}
コード例 #5
0
 function view()
 {
     $comment = Comments::findById(get_id());
     if (!$comment instanceof Comment) {
         flash_error(lang('comment dnx'));
         ajx_current("empty");
         return;
     }
     if (!$comment->canView(logged_user())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     $object = $comment->getRelObject();
     if (!$object instanceof ContentDataObject) {
         flash_error(lang('object dnx'));
         ajx_current("empty");
         return;
     }
     redirect_to($object->getViewUrl());
 }
コード例 #6
0
 function deactivate()
 {
     ajx_current("empty");
     $id = array_var($_POST, 'id');
     if ($plg = Plugins::instance()->findById($id)) {
         $plg->deactivate();
     }
 }
コード例 #7
0
 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));
 }
コード例 #8
0
 function set_timezone()
 {
     $tz = array_var($_REQUEST, 'tz');
     if ($tz != logged_user()->getTimezone()) {
         logged_user()->setTimezone($tz);
         logged_user()->save();
     }
     ajx_current("empty");
 }
コード例 #9
0
 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));
 }
コード例 #10
0
 function save_permission_group()
 {
     ajx_current("empty");
     if (!can_manage_dimension_members(logged_user())) {
         flash_error(lang('no access permissions'));
         return;
     }
     $member = Members::findById(array_var($_REQUEST, 'member_id'));
     if (!$member instanceof Member) {
         flash_error(lang('member dnx'));
         return;
     }
     $members = array($member);
     // if apply to submembers is checked get submembers verifying logged user permissions
     if (array_var($_REQUEST, 'apply_submembers') > 0) {
         $dimension = $member->getDimension();
         $pg_ids_str = implode(',', logged_user()->getPermissionGroupIds());
         $extra_conditions = "";
         if (!$dimension->hasAllowAllForContact($pg_ids_str)) {
             $extra_conditions = " AND EXISTS (SELECT cmp.member_id FROM " . TABLE_PREFIX . "contact_member_permissions cmp \r\n\t\t\t\t\tWHERE cmp.member_id=" . TABLE_PREFIX . "members.id AND cmp.permission_group_id IN (" . $pg_ids_str . "))";
         }
         $childs = $member->getAllChildren(true, null, $extra_conditions);
         $members = array_merge($members, $childs);
     }
     $pg_id = array_var($_REQUEST, 'pg_id');
     $permissions = array_var($_REQUEST, 'perms');
     $all_permissions = array();
     foreach ($members as $member) {
         $all_permissions[$member->getId()] = json_decode($permissions);
         foreach ($all_permissions[$member->getId()] as &$perm) {
             $perm->m = $member->getId();
         }
     }
     $all_permissions_str = json_encode(array_flat($all_permissions));
     $_POST['permissions'] = $all_permissions_str;
     try {
         DB::beginWork();
         $_POST['root_perm_genid'] = 'dummy_root_perm_genid';
         save_user_permissions_background(logged_user(), $pg_id, false, array(), true);
         $null = null;
         Hook::fire('after_save_member_permissions_for_pg', $_REQUEST, $null);
         DB::commit();
         flash_success(lang("permissions successfully saved"));
     } catch (Exception $e) {
         DB::rollback();
         flash_error($e->getMessage());
     }
 }
コード例 #11
0
 function fckimagesbrowser()
 {
     /* get query parameters */
     $this->setLayout('html');
     ajx_current("empty");
     $start = array_var($_GET, 'start');
     $limit = array_var($_GET, 'limit');
     if (!$start) {
         $start = 0;
     }
     if (!$limit) {
         $limit = config_option('files_per_page');
     }
     $order = array_var($_GET, 'sort');
     $orderdir = array_var($_GET, 'dir');
     $page = (int) ($start / $limit) + 1;
     $hide_private = !logged_user()->isMemberOfOwnerCompany();
     $project = active_project();
     $tag = array_var($_GET, 'tag');
     $type = '%image/';
     $paginatedImages = ProjectFiles::getProjectFiles($project, null, $hide_private, $order, $orderdir, $page, $limit, false, $tag, $type, logged_user()->getId());
     tpl_assign('start', $start);
     tpl_assign('limit', $limit);
     tpl_assign('paginatedImages', $paginatedImages);
 }
コード例 #12
0
 function print_mail()
 {
     $this->setLayout("html");
     $email = MailContents::findById(get_id());
     if (!$email instanceof MailContent) {
         flash_error(lang('email dnx'));
         ajx_current("empty");
         return;
     }
     if ($email->getIsDeleted()) {
         flash_error(lang('email dnx deleted'));
         ajx_current("empty");
         return;
     }
     if (!$email->canView(logged_user())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     if ($email->getBodyHtml() != '') {
         MailUtilities::parseMail($email->getContent(), $decoded, $parsedEmail, $warnings);
         $tmp_folder = "/tmp/" . $email->getAccountId() . "_" . logged_user()->getId() . "_" . $email->getId() . "_temp_mail_content_res";
         if (is_dir(ROOT . $tmp_folder)) {
             remove_dir(ROOT . $tmp_folder);
         }
         if ($parts_container = array_var($decoded, 0)) {
             $email->setBodyHtml(self::rebuild_body_html($email->getBodyHtml(), array_var($parts_container, 'Parts'), $tmp_folder));
         }
     }
     tpl_assign('email', $email);
     $this->setTemplate("print_view");
     //ajx_current("empty");
 }
コード例 #13
0
 /**
  * Delete group
  *
  * @param void
  * @return null
  */
 function delete()
 {
     if (!can_manage_security(logged_user())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     // if
     $group = Groups::findById(get_id());
     if (!$group instanceof Group) {
         flash_error(lang('group dnx'));
         ajx_current("empty");
         return;
     }
     // if
     try {
         DB::beginWork();
         $group->delete();
         ApplicationLogs::createLog($group, null, ApplicationLogs::ACTION_DELETE);
         DB::commit();
         flash_success(lang('success delete group', $group->getName()));
         ajx_current("reload");
     } catch (Exception $e) {
         DB::rollback();
         flash_error(lang('error delete group'));
         ajx_current("empty");
     }
     // try
 }
コード例 #14
0
 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));
 }
コード例 #15
0
 /**
  * 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()));
     }
 }
コード例 #16
0
 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);
 }
コード例 #17
0
 function set_timezone()
 {
     $tz = array_var($_REQUEST, 'tz');
     if ($tz != logged_user()->getTimezone()) {
         $sql = "UPDATE " . TABLE_PREFIX . "contacts SET timezone = '" . $tz . "'\r\n\t\t\tWHERE object_id = " . logged_user()->getId();
         DB::execute($sql);
     }
     ajx_current("empty");
 }
コード例 #18
0
 /**
  * Log user back in
  *
  * @access public
  * @param void
  * @return null
  */
 function relogin()
 {
     ajx_current("empty");
     $login_data = array_var($_POST, 'login');
     if (!is_array($login_data)) {
         $login_data = array();
     }
     // if
     $username = array_var($login_data, 'username');
     $password = array_var($login_data, 'password');
     $remember = array_var($login_data, 'remember', '') != '';
     if (function_exists('logged_user') && logged_user() instanceof Contact && logged_user()->getUsername() == $username && logged_user()->isUser()) {
         flash_error(lang("already logged in"));
         return;
     }
     // if
     if (trim($username == '')) {
         flash_error(lang("username value missing"));
         return;
     }
     // if
     if (trim($password) == '') {
         flash_error(lang("password value missing"));
         return;
     }
     // if
     $user = Contacts::getByUsername($username, owner_company());
     if (!($user instanceof Contact && $user->isUser()) || $user->getDisabled()) {
         flash_error(lang('invalid login data'));
         return;
     }
     // if
     if (!$user->isValidPassword($password)) {
         flash_error(lang('invalid login data'));
         return;
     }
     // if
     try {
         CompanyWebsite::instance()->logUserIn($user, $remember);
     } catch (Exception $e) {
         flash_error(lang('invalid login data'));
         return;
     }
     // try
 }
コード例 #19
0
function core_dimensions_after_object_controller_trash($ids)
{
    if (!is_array($ids) && $ids > 0) {
        $person_dim = Dimensions::findByCode('feng_persons');
        if ($person_dim instanceof Dimension) {
            $ot = ObjectTypes::findOne(array('conditions' => "`id` IN (SELECT `o`.`object_type_id` FROM `" . TABLE_PREFIX . "objects` `o` WHERE `o`.`id` = " . DB::escape(array_var($_GET, 'object_id')) . ")"));
            if ($ot && $ot->getName() == 'contact') {
                evt_add('select dimension member', array('dim_id' => $person_dim->getId(), 'node' => 'root'));
                ajx_current("empty");
                redirect_to(get_url('contact', 'init'));
            }
        }
    }
}
コード例 #20
0
	function zip_add() {
		if (logged_user()->isGuest()) {
			flash_error(lang('no access permissions'));
			ajx_current("empty");
			return;
		}
		ajx_current("empty");
		if (!zip_supported()) {
			flash_error(lang('zip not supported'));
			return;
		}

		$files = ProjectFiles::findByCSVIds(array_var($_GET, 'objects'), '`type` = 0');
		if (count($files) == 0) {
			flash_error(lang('no files to compress'));
			return;
		}
                
		$isnew = false;
		$file = null;
		if (array_var($_GET, 'filename')) {
			$filename = array_var($_GET, 'filename');
			$isnew = true;
		} else if (array_var($_GET, 'id')) {
			$file = ProjectFiles::findById(array_var($_GET, 'id'));
			$filename = $file->getFilename();
		}
		
		$tmp_zip_path = ROOT.'/tmp/'.rand().'.zip';
		$handle = fopen($tmp_zip_path, 'wb');
		if (!$isnew) {
			$content = $file->getLastRevision()->getFileContent();
			fwrite($handle, $content, $file->getLastRevision()->getFilesize());
		}
		fclose($handle);
		
		$zip = new ZipArchive();
		if (!$isnew) $zip->open($tmp_zip_path);
		else $zip->open($tmp_zip_path, ZipArchive::OVERWRITE);
		
		$tmp_dir = ROOT.'/tmp/'.rand().'/';
		mkdir($tmp_dir);
		$members = array();
		foreach ($files as $file_to_add) {
			if (FileRepository::getBackend() instanceof FileRepository_Backend_FileSystem) {
				$file_to_add_path = FileRepository::getBackend()->getFilePath($file_to_add->getLastRevision()->getRepositoryId());
			} else {
				$file_to_add_path = $tmp_dir . $file_to_add->getFilename();
				$handle = fopen($file_to_add_path, 'wb');
				fwrite($handle, $file_to_add->getLastRevision()->getFileContent(), $file_to_add->getLastRevision()->getFilesize());
				fclose($handle);
			}
			$zip->addFile($file_to_add_path, utf8_safe($file_to_add->getFilename()));
			$members[] = $file_to_add->getMemberIds();
		}
		$zip->close();
		delete_dir($tmp_dir);
                
		$this->upload_file($file, $filename, $tmp_zip_path, $members);
		unlink($tmp_zip_path);
		
		flash_success(lang('success compressing files', count($files)));
		ajx_current("reload");
	}
コード例 #21
0
 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));
     }
 }
コード例 #22
0
 function documents_allow_submit()
 {
     ajx_current("empty");
     if (!can_manage_security(logged_user())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     foreach ($_POST['file_types'] as $id => $extension) {
         $allow = $extension['allow'] == "on" ? 1 : 0;
         if ($ft = FileTypes::instance()->findById($id)) {
             $ft->setIsAllow($allow);
             $ft->save();
         }
     }
     flash_success(lang('success file extension'));
 }
コード例 #23
0
 function move()
 {
     if (logged_user()->isGuest()) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     ajx_current("empty");
     $id = get_id();
     $to = array_var($_GET, 'to', 0);
     // TODO: check permissions
     $ws = Projects::findById($id);
     $parent = Projects::findById($to);
     if (isset($ws)) {
         if ($to == 0 || isset($parent)) {
             $ws->setParentId($to);
             $ws->save();
             evt_add('workspace_edited', array("is" => $ws->getId(), "name" => $ws->getId(), "color" => $ws->getId(), "parent" => $ws->getParentId()));
         }
     }
 }
コード例 #24
0
 /**
  * Delete specific message
  *
  * @access public
  * @param void
  * @return null
  */
 function delete()
 {
     if (logged_user()->isGuest()) {
         flash_error(lang('no access permissions'));
         ajx_current('empty');
         return;
     }
     ajx_current("empty");
     $message = ProjectMessages::findById(get_id());
     if (!$message instanceof ProjectMessage) {
         flash_error(lang('message dnx'));
         ajx_current("empty");
         return;
     }
     // if
     if (!$message->canDelete(logged_user())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     // if
     try {
         DB::beginWork();
         $message->trash();
         DB::commit();
         ApplicationLogs::createLog($message, ApplicationLogs::ACTION_TRASH);
         flash_success(lang('success deleted message', $message->getObjectName()));
         if (array_var($_POST, 'popup', false)) {
             ajx_current("reload");
         } else {
             ajx_current("back");
         }
         ajx_add("overview-panel", "reload");
     } catch (Exception $e) {
         DB::rollback();
         flash_error(lang('error delete message'));
         ajx_current("empty");
     }
     // try
 }
コード例 #25
0
 function unarchive()
 {
     if (!can_manage_dimension_members(logged_user())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     $member = Members::findById(get_id());
     if (!$member instanceof Member) {
         flash_error(lang('member dnx'));
         ajx_current("empty");
         return;
     }
     if (get_id('user')) {
         $user = Contacts::findById($get_id('user'));
     } else {
         $user = logged_user();
     }
     if (!$user instanceof Contact) {
         ajx_current("empty");
         return;
     }
     try {
         DB::beginWork();
         set_time_limit(0);
         $count = $member->unarchive($user);
         evt_add("reload dimension tree", $member->getDimensionId());
         ajx_current("back");
         flash_success(lang('success unarchive member', $member->getName(), $count));
         DB::commit();
     } catch (Exception $e) {
         DB::rollback();
         flash_error($e->getMessage());
         ajx_current("empty");
     }
 }
コード例 #26
0
 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)));
 }
コード例 #27
0
	function get_companies_json() {
		$data = array();
		
		$check_permissions = array_var($_REQUEST, 'check_p');
		$allow_none = array_var($_REQUEST, 'allow_none', true);
		
		if (!$check_permissions) {
			$comp_rows = DB::executeAll("SELECT c.object_id, c.first_name FROM ".TABLE_PREFIX."contacts c INNER JOIN ".TABLE_PREFIX."objects o ON o.id=c.object_id
			WHERE c.is_company = 1 AND o.trashed_by_id = 0 AND o.archived_by_id = 0 ORDER BY c.first_name ASC");
		} else {
			$companies = Contacts::getVisibleCompanies(logged_user(), "`id` <> " . owner_company()->getId());
			if (logged_user()->isMemberOfOwnerCompany() || owner_company()->canAddUser(logged_user())) {
				// add the owner company
				$companies = array_merge(array(owner_company()), $companies);
			}
		}
		if ($allow_none) {
			$data[] = array('id' => 0, 'name' => lang('none'));
		}
		if (isset($comp_rows)) {
			foreach ($comp_rows as $row) {
				$data[] = array('id' => $row['object_id'], 'name' => $row['first_name']);
			}
		} else if (isset($companies)) {
			foreach ($companies as $company) {
				$data[] = array('id' => $company->getId(), 'name' => $company->getObjectName());
			}
		}
		
		$this->setAutoRender(false);
		echo json_encode($data);
		ajx_current("empty");
	}
コード例 #28
0
 function dimension_options_submit()
 {
     ajx_current("empty");
     if (!can_manage_dimensions(logged_user())) {
         flash_error(lang('no access permissions'));
         return;
     }
     $folder_ots = ObjectTypes::findAll(array('id' => true, 'conditions' => "name IN ('folder','project_folder','customer_folder')"));
     $data = array_var($_POST, 'enabled_dots');
     $names_data = array_var($_POST, 'custom_names');
     if (is_array($data) || is_array($names_data)) {
         try {
             DB::beginWork();
             // enabled dimension object types
             foreach ($data as $dim_id => $ots_info) {
                 foreach ($ots_info as $ot_id => $enabled) {
                     DB::execute("UPDATE " . TABLE_PREFIX . "dimension_object_types SET enabled=" . DB::escape($enabled) . " \r\n\t\t\t\t\t\t\tWHERE dimension_id=" . DB::escape($dim_id) . " AND object_type_id=" . DB::escape($ot_id));
                     // if object type is folder, set the same configuration to all folder types
                     if (in_array($ot_id, $folder_ots)) {
                         DB::execute("UPDATE " . TABLE_PREFIX . "dimension_object_types SET enabled=" . DB::escape($enabled) . "\r\n\t\t\t\t\t\t\t\tWHERE dimension_id=" . DB::escape($dim_id) . " AND object_type_id IN (" . implode(',', $folder_ots) . ")");
                     }
                 }
             }
             // custom dimension names
             foreach ($names_data as $dim_id => $custom_name) {
                 $cname = trim($custom_name);
                 $dimension = Dimensions::getDimensionById($dim_id);
                 if ($dimension instanceof Dimension) {
                     $dimension->setOptionValue('custom_dimension_name', $cname);
                 }
             }
             DB::commit();
             flash_success(lang("success edit dimension options"));
             evt_add('tabs changed');
             //ajx_current("back");
         } catch (Exception $e) {
             DB::rollback();
             flash_error($e->getMessage());
             ajx_current("empty");
         }
     }
 }
コード例 #29
0
 function update_unset_billing_values()
 {
     ajx_current("empty");
     if (!logged_user()->isAdministrator()) {
         flash_error(lang("no access permissions"));
         return;
     }
     try {
         DB::beginWork();
         $count = Timeslots::updateBillingValues();
         DB::commit();
         flash_success(lang("success update billing values", $count));
     } catch (Exception $e) {
         DB::rollback();
         flash_error($e->getMessage());
     }
 }
コード例 #30
0
 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");
 }