/** * Return all project files that were automatically checked out (on edit) by the user * * @param User $user * @return array */ static function closeAutoCheckedoutFilesByUser($user = null) { if (!$user) { $user = logged_user(); } try { $condstr = 'checked_out_by_id = ' . $user->getId() . ' AND was_auto_checked_out = 1 AND checked_out_on <> \'' . EMPTY_DATETIME . '\''; $files = self::findAll(array('conditions' => $condstr)); // findAll if ($files) { foreach ($files as $file) { $file->setWasAutoCheckedAuto($autoCheckOut); $file->setCheckedOutById(0); $file->setCheckedOutOn(EMPTY_DATETIME); $file->setMarkTimestamps(false); $file->save(); } return true; } return false; } catch (Exception $exc) { flash_error(lang('error checkin file')); return false; } }
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"); } }
/** * Show and process config category form * * @param void * @return null */ function update_category() { $category = ConfigCategories::findById(get_id()); if (!$category instanceof ConfigCategory) { flash_error(lang('config category dnx')); $this->redirectToReferer(get_url('administration')); } // if if ($category->isEmpty()) { flash_error(lang('config category is empty')); $this->redirectToReferer(get_url('administration')); } // if $options = $category->getOptions(false); $categories = ConfigCategories::getAll(false); tpl_assign('category', $category); tpl_assign('options', $options); tpl_assign('config_categories', $categories); $submitted_values = array_var($_POST, 'options'); if (is_array($submitted_values)) { foreach ($options as $option) { $new_value = array_var($submitted_values, $option->getName()); if (is_null($new_value) || $new_value == $option->getValue()) { continue; } $option->setValue($new_value); $option->save(); } // foreach flash_success(lang('success update config category', $category->getDisplayName())); $this->redirectTo('administration', 'configuration'); } // if $this->setSidebar(get_template_path('update_category_sidebar', 'config')); }
/** * Determine if a user canGoOn to deny access to files in projects * to which the user has not been assigned. * * @access public * @return null */ function canGoOn() { if (active_project() == null || !logged_user()->isProjectUser(active_project())) { flash_error(lang('no access permissions')); $this->redirectTo('dashboard'); } // if }
/** * Log user in * * @param void * @return null */ function login() { $redirect_to = null; // Get page user wanted to visit based on GET params if ($this->request->get('re_route')) { $params = array(); foreach ($this->request->url_params as $k => $v) { if ($k != 're_route' && str_starts_with($k, 're_')) { $params[substr($k, 3)] = $v; } // if } // if $redirect_to = assemble_url($this->request->get('re_route'), $params); } else { $redirect_to = assemble_url('dashboard'); } // if // If user is already logged in redirect him to page he wanted to visit if (instance_of($this->logged_user, 'User')) { flash_error('You are already logged in as :display. Please logout before you can login on another account', array('display' => $this->logged_user->getDisplayName())); $this->redirectToUrl($redirect_to); } // if $login_data = $this->request->post('login'); $this->smarty->assign(array('login_data' => $login_data, 'auto_focus' => true)); if ($this->request->isSubmitted()) { $errors = new ValidationErrors(); $email = trim(array_var($login_data, 'email')); $password = array_var($login_data, 'password'); $remember = (bool) array_var($login_data, 'remember'); if ($email == '') { $errors->addError(lang('Email address is required'), 'email'); } // if if (trim($password) == '') { $errors->addError(lang('Password is required'), 'password'); } // if if ($errors->hasErrors()) { $this->smarty->assign('auto_focus', false); $this->smarty->assign('errors', $errors); $this->render(); } // if $user =& $this->authentication->provider->authenticate(array('email' => $email, 'password' => $password, 'remember' => $remember)); if (!$user || is_error($user)) { $errors->addError(lang('Failed to log you in with data you provided. Please try again'), 'login'); $this->smarty->assign('errors', $errors); $this->render(); } // if flash_success(lang('Welcome back :display!', array('display' => $user->getDisplayName()), true, $user->getLanguage()), null, true); $this->redirectToUrl($redirect_to); } // if }
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()); } }
/** * Show project objects tagged with specific tag * * @access public * @param void * @return null */ function project_tag() { $tag = array_var($_GET, 'tag'); if (trim($tag) == '') { flash_error(lang('tag dnx')); $this->redirectTo('project', 'tags'); } // if $tagged_objects = active_project()->getObjectsByTag($tag); $total_tagged_objects = 0; if (is_array($tagged_objects)) { foreach ($tagged_objects as $type => $objects) { if (is_array($objects)) { $total_tagged_objects += count($objects); } } // foreach } // if tpl_assign('tag', $tag); tpl_assign('tagged_objects', $tagged_objects); tpl_assign('total_tagged_objects', $total_tagged_objects); }
/** * Attach object to specific page and redirects to specified page * * @access public * @param void * @return null */ function add_attachment() { $project = active_project(); if (!$project instanceof Project) { flash_error(lang('project dnx')); $this->redirectToReferer(get_url('dashboard')); } // if if (!$project->canEdit(logged_user())) { flash_error(lang('no access permissions')); $this->redirectToReferer(get_url('dashboard')); } // if $page_attachment = new PageAttachment(); $page_attachment->setText(lang('description')); $page_attachment->setRelObjectId('0'); $page_attachment->setRelObjectManager(array_var($_GET, 'rel_object_manager')); $page_attachment->setProjectId($project->getId()); $page_attachment->setPageName(array_var($_GET, 'page_name')); $page_attachment->setOrder(array_var($_GET, 'order')); $page_attachment->save(); PageAttachments::reorder(array_var($_GET, 'page_name'), $project); $this->redirectToReferer(get_url('dashboard')); }
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()); }
/** * Show permission update form * * @param void * @return null */ function permissions() { if (!active_project()->canChangePermissions(logged_user())) { flash_error(lang('no access permissions')); $this->redirectToUrl(active_project()->getOverviewUrl()); } // if $project_init = array_var($_GET, 'project_init'); tpl_assign('project_init', $project_init); tpl_assign('project_users', active_project()->getUsers(false)); tpl_assign('project_companies', active_project()->getCompanies()); tpl_assign('user_projects', logged_user()->getProjects()); $permissions = PermissionManager::getPermissionsText(); tpl_assign('permissions', $permissions); $companies = array(owner_company()); $clients = owner_company()->getClientCompanies(); if (is_array($clients)) { $companies = array_merge($companies, $clients); } // if tpl_assign('companies', $companies); if (array_var($_POST, 'process') == 'process') { try { DB::beginWork(); active_project()->clearCompanies(); active_project()->clearUsers(); $companies = array(owner_company()); $client_companies = owner_company()->getClientCompanies(); if (is_array($client_companies)) { $companies = array_merge($companies, $client_companies); } // if foreach ($companies as $company) { // Company is selected! if (array_var($_POST, 'project_company_' . $company->getId()) == 'checked') { // Owner company is automaticly included so it does not need to be in project_companies table if (!$company->isOwner()) { $project_company = new ProjectCompany(); $project_company->setProjectId(active_project()->getId()); $project_company->setCompanyId($company->getId()); $project_company->save(); } // if $users = $company->getUsers(); if (is_array($users)) { $counter = 0; foreach ($users as $user) { $user_id = $user->getId(); $counter++; if (array_var($_POST, "project_user_{$user_id}") == 'checked') { $project_user = new ProjectUser(); $project_user->setProjectId(active_project()->getId()); $project_user->setUserId($user_id); foreach ($permissions as $permission => $permission_text) { // Owner company members have all permissions $permission_value = $company->isOwner() ? true : array_var($_POST, 'project_user_' . $user_id . '_' . $permission) == 'checked'; $setter = 'set' . Inflector::camelize($permission); $project_user->{$setter}($permission_value); } // if $project_user->save(); } // if } // foreach } // if } // if } // foreach DB::commit(); flash_success(lang('success update project permissions')); if ($project_init) { $this->redirectToUrl(active_project()->getEditUrl(active_project()->getOverviewUrl())); } else { $this->redirectTo('project_settings', 'users'); } // if } catch (Exception $e) { DB::rollback(); flash_error(lang('error update project permissions')); $this->redirectTo('project_settings', 'permissions'); } // try } // if }
/** * @author Ignacio Vazquez <elpepe.uy at gmail dot com> * Handle quick add submit */ function quick_add() { if (array_var($_GET, 'current') == 'overview-panel') { ajx_current("reload"); }else { ajx_current("empty"); } //---------- REQUEST PARAMS -------------- // $_POST = Array ( // [member] => Array ( // [name] => pepe 333 // [dimension_id] => 1 // [parent_member_id] => 0 // [dimension_id] => 19 // ) // [contact] => Array ( // [email] => slkdjflksjdflksdf@kldsjflkdf.com // [user] => Array ( // [create-user]=>on // [type] => 25 // [first_name] => // [surname] => // ) //---------------------------------------- // Init variables $max_users = config_option('max_users'); if ($max_users && (Contacts::count() >= $max_users)) { flash_error(lang('maximum number of users reached error')); ajx_current("empty"); return; } if (!can_manage_security(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } $email = trim(array_var(array_var($_POST, 'contact'),'email')) ; $member = array_var($_POST, 'member'); $name = array_var($member, 'name'); $firstName = trim(array_var(array_var($_POST, 'contact'),'first_name')); $surname = trim(array_var(array_var($_POST, 'contact'),'surname')); $parentMemberId = array_var($member, 'parent_member_id'); $objectType = ObjectTypes::findById(array_var($member, 'object_type_id'))->getName(); // 'person', 'company' $dimensionId = array_var($member, 'dimension_id'); $company = array_var(array_var(array_var($_POST, 'contact'),'user'),'company_id'); // Create new instance of Contact and set the basic fields $contact = new Contact(); $contact->setObjectName($name); if ($firstName) { $contact->setFirstName($firstName); }else{ $contact->setFirstName($name); } if ($surname) { $contact->setSurname($surname); } $contact->setCompanyId($company); $contact->setIsCompany($objectType == "company"); if ($parentMemberId){ if ( $companyId = Members::findById($parentMemberId)->getObjectId()) { $contact->setCompanyId($companyId); } } // Save Contact try { DB::beginWork(); $contact->save(); if ($email && is_valid_email($email)) { if (!Contacts::validateUniqueEmail($email)) { DB::rollback(); flash_error(lang("email address must be unique")); return false; }else{ if (!array_var (array_var(array_var($_POST, 'contact'),'user'), 'create-user')) { $contact->addEmail($email, 'personal', true); } flash_success(lang("success add contact", $contact->getObjectName())); } } // User settings $user = array_var(array_var($_POST, 'contact'),'user'); $user['username'] = str_replace(" ","",strtolower($name)) ; $this->createUserFromContactForm($user, $contact->getId(), $email); // Reload contact again due to 'createUserFromContactForm' changes Hook::fire("after_contact_quick_add", Contacts::instance()->findById($contact->getId()), $ret); DB::commit(); }catch (Exception $e){ DB::rollback(); flash_error($e->getMessage()); } // Reload evt_add("reload dimension tree", array('dim_id' => $dimensionId)); }
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"); } }
function delete_custom_report() { if (logged_user()->isGuest()) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } $report_id = array_var($_GET, 'id'); $report = Reports::getReport($report_id); if (!$report->canDelete(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } // if try { DB::beginWork(); $report->delete(); DB::commit(); ajx_current("reload"); } catch (Exception $e) { DB::rollback(); flash_error($e->getMessage()); ajx_current("empty"); } // try }
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()); } }
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())); } } }
function repetitive_task_related_edit($task, $task_data) { $was_template = $task->getIsTemplate(); $task->setFromAttributes($task_data); $task->setIsTemplate($was_template); // is_template value must not be changed from ui $totalMinutes = array_var($task_data, 'time_estimate_hours') * 60 + array_var($task_data, 'time_estimate_minutes'); $task->setTimeEstimate($totalMinutes); if ($task->getParentId() > 0 && $task->hasChild($task->getParentId())) { flash_error(lang('task child of child error')); ajx_current("empty"); return; } DB::beginWork(); $task->save(); $task->setObjectName(array_var($task_data, 'name')); $task->save(); // dependencies if (config_option('use tasks dependencies')) { $previous_tasks = array_var($task_data, 'previous'); if (is_array($previous_tasks)) { foreach ($previous_tasks as $ptask) { if ($ptask == $task->getId()) { continue; } $dep = ProjectTaskDependencies::findById(array('previous_task_id' => $ptask, 'task_id' => $task->getId())); if (!$dep instanceof ProjectTaskDependency) { $dep = new ProjectTaskDependency(); $dep->setPreviousTaskId($ptask); $dep->setTaskId($task->getId()); $dep->save(); } } $saved_ptasks = ProjectTaskDependencies::findAll(array('conditions' => 'task_id = ' . $task->getId())); foreach ($saved_ptasks as $pdep) { if (!in_array($pdep->getPreviousTaskId(), $previous_tasks)) { $pdep->delete(); } } } else { ProjectTaskDependencies::delete('task_id = ' . $task->getId()); } } // Add assigned user to the subscibers list if ($task->getAssignedToContactId() > 0 && Contacts::instance()->findById($task->getAssignedToContactId())) { if (!isset($_POST['subscribers'])) { $_POST['subscribers'] = array(); } $_POST['subscribers']['user_' . $task->getAssignedToContactId()] = 'checked'; } $object_controller = new ObjectController(); $object_controller->add_to_members($task, array_var($task_data, 'members')); $object_controller->add_subscribers($task); $object_controller->link_to_new_object($task); $object_controller->add_custom_properties($task); $object_controller->add_reminders($task); // apply values to subtasks $assigned_to = $task->getAssignedToContactId(); $subtasks = $task->getAllSubTasks(); $milestone_id = $task->getMilestoneId(); $apply_ms = array_var($task_data, 'apply_milestone_subtasks') == "checked"; $apply_at = array_var($task_data, 'apply_assignee_subtasks', '') == "checked"; foreach ($subtasks as $sub) { $modified = false; if ($apply_at || !($sub->getAssignedToContactId() > 0)) { $sub->setAssignedToContactId($assigned_to); $modified = true; } if ($apply_ms) { $sub->setMilestoneId($milestone_id); $modified = true; } if ($modified) { $sub->save(); } } $task->resetIsRead(); ApplicationLogs::createLog($task, ApplicationLogs::ACTION_EDIT); DB::commit(); }
/** * Detach file from related object * * @param void * @return null */ function detach_from_object() { $manager_class = array_var($_GET, 'manager'); $object_id = get_id('object_id'); $file_id = get_id('file_id'); $object = get_object_by_manager_and_id($object_id, $manager_class); if (!$object instanceof ProjectDataObject) { flash_error(lang('no access permissions')); $this->redirectToReferer(get_url('dashboard')); } // if $file = ProjectFiles::findById($file_id); if (!$file instanceof ProjectFile) { flash_error(lang('file dnx')); $this->redirectToReferer(get_url('dashboard')); } // if $attached_file = AttachedFiles::findById(array('rel_object_manager' => $manager_class, 'rel_object_id' => $object_id, 'file_id' => $file_id)); // findById if (!$attached_file instanceof AttachedFile) { flash_error(lang('file not attached to object')); $this->redirectToReferer(get_url('dashboard')); } // if try { DB::beginWork(); $attached_file->delete(); DB::commit(); flash_success(lang('success detach file')); } catch (Exception $e) { flash_error(lang('error detach file')); DB::rollback(); } // try $this->redirectToReferer($object->getObjectUrl()); }
/** * Delete avatar * * @param void * @return null */ function delete_avatar() { $user = Users::findById(get_id()); if (!$user instanceof User) { flash_error(lang('user dnx')); $this->redirectTo('dashboard'); } // if if (!$user->canUpdateProfile(logged_user())) { flash_error(lang('no access permissions')); $this->redirectTo('dashboard'); } // if $redirect_to = array_var($_GET, 'redirect_to'); if (trim($redirect_to) == '' || !is_valid_url($redirect_to)) { $redirect_to = $user->getUpdateAvatarUrl(); } // if tpl_assign('redirect_to', $redirect_to); if (!$user->hasAvatar()) { flash_error(lang('avatar dnx')); $this->redirectToUrl($redirect_to); } // if try { DB::beginWork(); $user->deleteAvatar(); $user->save(); ApplicationLogs::createLog($user, null, ApplicationLogs::ACTION_EDIT); DB::commit(); flash_success(lang('success delete avatar')); } catch (Exception $e) { DB::rollback(); flash_error(lang('error delete avatar')); } // try $this->redirectToUrl($redirect_to); }
/** * Delete specific project form * * @param void * @return null */ function delete() { $project_form = ProjectForms::findById(get_id()); if (!$project_form instanceof ProjectForm) { flash_error(lang('project form dnx')); if (ProjectForm::canAdd(logged_user(), active_project())) { $this->redirectTo('form'); } else { $this->redirectToUrl(active_project()->getOverviewUrl()); } // if } // if if (!$project_form->canDelete(logged_user())) { flash_error(lang('no access permissions')); if (ProjectForm::canAdd(logged_user(), active_project())) { $this->redirectTo('form'); } else { $this->redirectToUrl(active_project()->getOverviewUrl()); } // if } // if if ($project_form->delete()) { ApplicationLogs::createLog($project_form, active_project(), ApplicationLogs::ACTION_DELETE, true); flash_success(lang('success delete project form', $project_form->getName())); } else { flash_error(lang('error delete project form')); } // if $this->redirectTo('form'); }
function list_members() { if (!logged_user()->isAdminGroup()) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } ajx_set_no_toolbar(); $dim_id = array_var($_REQUEST, 'dim', 0); $dimension = Dimensions::findById($dim_id); if (!$dimension instanceof Dimension) { flash_error(lang('dimension snx')); ajx_current("empty"); return; } if (isset($_REQUEST['page'])) { ajx_replace(true); } // parameters $page = array_var($_REQUEST, 'page'); $order_by = array_var($_REQUEST, 'order'); $order_by_dir = array_var($_REQUEST, 'order_dir'); // pagination params $items_x_page = array_var($_REQUEST, 'items_x_page', 20); if (!$page) { $page = 1; } $offset = $items_x_page * ($page - 1); // order defaults if (!$order_by) { $order_by = 'name'; } if (!in_array($order_by_dir, array('ASC', 'DESC'))) { $order_by_dir = 'ASC'; } // this function already checks dimension options $dim_name = $dimension->getName(); // permissions sql $perm_sql = ""; if ($dimension->getDefinesPermissions() && !logged_user()->isAdministrator()) { $pg_ids = logged_user()->getPermissionGroupIds(); $perm_sql = " AND EXISTS (SELECT cmp.member_id FROM " . TABLE_PREFIX . "contact_member_permissions cmp WHERE cmp.member_id=m.id AND cmp.permission_group_id IN (" . implode(',', $pg_ids) . "))"; } $main_sql = "SELECT m.id, l.created_on, l.created_by_id, l.member_id FROM " . TABLE_PREFIX . "members m LEFT JOIN " . TABLE_PREFIX . "application_logs l ON l.member_id=m.id AND l.action='add' WHERE m.dimension_id='{$dim_id}' {$perm_sql}"; $sql = "{$main_sql}\r\n\t\t\t\tORDER BY {$order_by} {$order_by_dir} \r\n\t\t\t\tLIMIT {$offset}, {$items_x_page}"; $rows = DB::executeAll($sql); $count_sql = str_replace("SELECT m.id, l.created_on, l.created_by_id, l.member_id FROM", "SELECT count(*) as total FROM", $main_sql); $count_row = DB::executeAll($count_sql); $members = array(); $ids = array(); $log_data = array(); foreach ($rows as $row) { $members[] = Members::findById($row['id']); $log_data[$row['id']] = array('created_on' => $row['created_on'], 'created_by_id' => $row['created_by_id']); } $member_type_ids = array_flat(DB::executeAll("SELECT object_type_id FROM " . TABLE_PREFIX . "dimension_object_types WHERE dimension_id={$dim_id} AND is_root=1")); $member_types = ObjectTypes::findAll(array('conditions' => 'id IN (' . implode(',', $member_type_ids) . ')')); tpl_assign('members', $members); tpl_assign('log_data', $log_data); tpl_assign('dimension', $dimension); tpl_assign('dimension_name', $dim_name); tpl_assign('member_types', $member_types); tpl_assign('page', $page); tpl_assign('total_items', $count_row[0]['total']); tpl_assign('items_x_page', $items_x_page); tpl_assign('order_by', $order_by); tpl_assign('order_by_dir', $order_by_dir); }
/** * Toggle favorite status * * @param void * @return null */ function toggle_favorite() { if (!logged_user()->isAdministrator()) { flash_error('no access permisssions'); $this->redirectToReferer(get_url('dashboard')); } $company = Companies::findById(get_id()); if (!$company instanceof Company) { flash_error(lang('company dnx')); $this->redirectToReferer(get_url('administration')); } // if if ($company->isOwner()) { flash_error('no access permissions'); $this->redirectToReferer(get_url('dashboard')); } // if $company->setIsFavorite(!$company->isFavorite()); if (!$company->save()) { flash_error(lang('could not save info')); } $redirect_to = urldecode(array_var($_GET, 'redirect_to')); if (trim($redirect_to) == '' || !is_valid_url($redirect_to)) { $redirect_to = $company->getViewUrl(); } // if $this->redirectToUrl($redirect_to); }
require_once "../common.php"; if ($_SERVER['REQUEST_METHOD'] == "POST") { $lang = safepost('lang'); $fUsername = trim(safepost('fUsername')); $fPassword = safepost('fPassword'); if ($lang != check_language(0)) { # only set cookie if language selection was changed setcookie('lang', $lang, time() + 60 * 60 * 24 * 30); # language cookie, lifetime 30 days # (language preference cookie is processed even if username and/or password are invalid) } $h = new MailboxHandler(); if ($h->login($fUsername, $fPassword)) { session_regenerate_id(); $_SESSION['sessid'] = array(); $_SESSION['sessid']['roles'] = array(); $_SESSION['sessid']['roles'][] = 'user'; $_SESSION['sessid']['username'] = $fUsername; $_SESSION['PFA_token'] = md5(uniqid(rand(), true)); header("Location: main.php"); exit; } else { error_log("PostfixAdmin login failed (username: {$fUsername})"); flash_error($PALANG['pLogin_failed']); } } $smarty->assign('language_selector', language_selector(), false); $smarty->assign('smarty_template', 'login'); $smarty->assign('logintype', 'user'); $smarty->display('index.tpl'); /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */
/** * Show calendar view milestone page * * @access public * @param void * @return null */ function calendar() { $this->addHelper('textile'); $project = active_project(); $id = get_id(); if (strlen($id) == 0) { $id = gmdate('Ym'); } if (preg_match('/^(\\d{4})(\\d{2})$/', $id, $matches)) { list(, $year, $month) = $matches; tpl_assign('year', $year); tpl_assign('month', $month); } else { flash_error(lang('id missing')); $this->redirectToReferer(get_url('milestone')); } tpl_assign('milestones', $project->getMilestonesByMonth($year, $month)); }
/** * Unsubscribe from message * * @param void * @return null */ function unsubscribe() { $ticket = ProjectTickets::findById(get_id()); if (!$ticket instanceof ProjectTicket) { flash_error(lang('ticket dnx')); $this->redirectTo('tickets'); } // if if (!$ticket->canView(logged_user())) { flash_error(lang('no access permissions')); $this->redirectTo('tickets'); } // if if ($ticket->unsubscribeUser(logged_user())) { flash_success(lang('success unsubscribe to ticket')); } else { flash_error(lang('error unsubscribe to ticket')); } // if $this->redirectToUrl($ticket->getViewUrl()); }
/** * Hide welcome info message * * @param void * @return null */ function hide_welcome_info() { if (!logged_user()->isAdministrator(owner_company())) { flash_error(lang('no access permissions')); $this->redirectTo('dashboard'); } // if try { owner_company()->setHideWelcomeInfo(true); owner_company()->save(); flash_success(lang('success hide welcome info')); } catch (Exception $e) { flash_error(lang('error hide welcome info')); } // try $this->redirectTo('dashboard'); }
/** * Delete comment * * @access public * @param void * @return null */ function delete_comment() { $comment = MessageComments::findById(get_id()); if (!$comment instanceof MessageComment) { flash_error(lang('comment dnx')); $this->redirectTo('message'); } // if $message = $comment->getMessage(); if (!$message instanceof ProjectMessage) { flash_error(lang('message dnx')); $this->redirectTo('message'); } // if if (!$comment->canDelete(logged_user())) { flash_error(lang('no access permissions')); $this->redirectToUrl($message->getViewUrl()); } // if try { DB::beginWork(); $comment->delete(); ApplicationLogs::createLog($comment, active_project(), ApplicationLogs::ACTION_DELETE); DB::commit(); flash_success(lang('success delete comment')); } catch (Exception $e) { DB::rollback(); flash_error(lang('error delete comment')); } // try $this->redirectToUrl($message->getViewUrl()); }
/** * Create new comment * * @param void * @return null */ function add() { $this->wireframe->print_button = false; $active_object = ProjectObjects::findById($this->request->getId('parent_id')); if (!instance_of($active_object, 'ProjectObject')) { $this->httpError(HTTP_ERR_NOT_FOUND, null, true, $this->request->isApiCall()); } // if if (!$active_object->canComment($this->logged_user)) { $this->httpError(HTTP_ERR_FORBIDDEN, null, true, $this->request->isApiCall()); } // if $active_object->prepareProjectSectionBreadcrumb($this->wireframe); $this->wireframe->addBreadCrumb($active_object->getName(), $active_object->getViewUrl()); if (!$active_object->canComment($this->logged_user)) { if ($this->request->isApiCall()) { $this->httpError(HTTP_ERR_FORBIDDEN, null, true, true); } else { flash_error('Parent object not found'); $this->redirectToReferer($this->active_project->getOverviewUrl()); } // if } // if $comment_data = $this->request->post('comment'); $this->smarty->assign(array('active_object' => $active_object, 'page_tab' => $active_object->getProjectTab(), 'comment_data' => $comment_data, 'recent_comments' => Comments::findRecentObject($active_object, 5, STATE_VISIBLE, $this->logged_user->getVisibility()))); if ($this->request->isSubmitted()) { db_begin_work(); $complete_parent_object = (bool) array_var($comment_data, 'complete_parent_object'); $this->active_comment = new Comment(); $this->active_comment->log_activities = false; if ($complete_parent_object) { $this->active_comment->send_notification = false; } // if attach_from_files($this->active_comment, $this->logged_user); $this->active_comment->setAttributes($comment_data); $this->active_comment->setParent($active_object); $this->active_comment->setProjectId($this->active_project->getId()); $this->active_comment->setState(STATE_VISIBLE); $this->active_comment->setVisibility($active_object->getVisibility()); if (trim($this->active_comment->getCreatedByName()) == '' || trim($this->active_comment->getCreatedByEmail()) == '') { $this->active_comment->setCreatedBy($this->logged_user); } // if $save = $this->active_comment->save(); if ($save && !is_error($save)) { $active_object->subscribe($this->logged_user); $activity = new NewCommentActivityLog(); $activity->log($this->active_comment, $this->logged_user); if ($complete_parent_object && $active_object->canChangeCompleteStatus($this->logged_user)) { $active_object->complete($this->logged_user, $this->active_comment->getFormattedBody(true)); } // if db_commit(); $this->active_comment->ready(); //BOF: mod $subscribers_to_notify = array_var($comment_data, 'subscribers_to_notify'); $action_request_user_id = array_var($comment_data, 'action_request'); //$priority_actionrequest = array_var($comment_data, 'priority_actionrequest'); //BOF:mod 20110517 if ($complete_parent_object) { $subscribers_to_notify = array(); $action_request_user_id = array(); } //EOF:mod 20110517 //BOF:mod 20110719 /* //EOF:mod 20110719 if (!empty($action_request_user_id)){ $link = mysql_connect(DB_HOST, DB_USER, DB_PASS); mysql_select_db(DB_NAME); foreach ($action_request_user_id as $id){ $query = "select * from healingcrystals_assignments_action_request where comment_id='" . $this->active_comment->getId() . "' and selected_by_user_id='" . $this->logged_user->getId() . "' and user_id='" . $id . "'"; $result = mysql_query($query); if (mysql_num_rows($result)){ $query = "update healingcrystals_assignments_action_request set is_action_request='1' where comment_id='" . $this->active_comment->getId() . "' and selected_by_user_id='" . $this->logged_user->getId() . "' and user_id='" . $id . "'"; mysql_query($query); } else { $query = "insert into healingcrystals_assignments_action_request (user_id, is_action_request, is_fyi, selected_by_user_id, comment_id, date_added) values ('" . $id . "', '1', '0', '" . $this->logged_user->getId() . "', '" . $this->active_comment->getId() . "', now())"; mysql_query($query); } } foreach($priority_actionrequest as $val){ $temp = explode('_', $val); list($temp_user_id, $priority) = $temp; if (in_array($temp_user_id, $action_request_user_id)){ $query = "update healingcrystals_assignments_action_request set priority_actionrequest='" . $priority . "' where comment_id='" . $this->active_comment->getId() . "' and selected_by_user_id='" . $this->logged_user->getId() . "' and user_id='" . $temp_user_id . "'"; mysql_query($query); } } mysql_close($link); } //BOF:mod 20110719 */ //EOF:mod 20110719 //BOF:mod 20110719 //$action_request_user_id = array(); //if (!empty($priority_actionrequest)){ $link = mysql_connect(DB_HOST, DB_USER, DB_PASS); mysql_select_db(DB_NAME); if (!empty($action_request_user_id)) { //foreach($priority_actionrequest as $val){ foreach ($action_request_user_id as $val) { //$temp = explode('_', $val); //list($temp_user_id, $priority) = $temp; $temp_user_id = $val; $priority = '0'; //if ((int)$priority>-10){ $query = "select * from healingcrystals_assignments_action_request where comment_id='" . $this->active_comment->getId() . "' and selected_by_user_id='" . $this->logged_user->getId() . "' and user_id='" . $temp_user_id . "'"; $result = mysql_query($query, $link); if (mysql_num_rows($result)) { $query1 = "update healingcrystals_assignments_action_request set is_action_request='1', priority_actionrequest='" . $priority . "' where comment_id='" . $this->active_comment->getId() . "' and selected_by_user_id='" . $this->logged_user->getId() . "' and user_id='" . $temp_user_id . "'"; mysql_query($query1, $link); } else { $query1 = "insert into healingcrystals_assignments_action_request (user_id, is_action_request, is_fyi, selected_by_user_id, comment_id, date_added, priority_actionrequest) values ('" . $temp_user_id . "', '1', '0', '" . $this->logged_user->getId() . "', '" . $this->active_comment->getId() . "', now(), '" . $priority . "')"; mysql_query($query1, $link); } //$action_request_user_id[] = $temp_user_id; $task = new Task(); $task->setProjectId(TASK_LIST_PROJECT_ID); $task->setParentId(Page::getTaskPageIdForUser($val)); $task->setParentType('Page'); $task->setCreatedBy($this->logged_user); $task->setVisibility(VISIBILITY_NORMAL); $task->setState(STATE_VISIBLE); $task_body = ''; $parent = $this->active_comment->getParent(); $url = $parent->getViewUrl() . '#comment' . $this->active_comment->getId(); $comment_body = $this->active_comment->getBody(); $comment_body = strip_tags($comment_body); //$task_body = substr($comment_body, 0, 10) . '.. <br/><a href="' . $url . '">View Task in Full</a>'; if (strlen($comment_body) > 525) { $task_body .= substr($comment_body, 0, 525) . '..'; } else { $task_body .= $comment_body; } $task_body .= '<br/><a href="' . $url . '">View Task in Full</a>'; $attachments = $this->active_comment->getAttachments(); if (is_foreachable($attachments)) { $task_body .= '<br/>Attachments:<br/>'; foreach ($attachments as $attachment) { $task_body .= '<a href="' . $attachment->getViewUrl() . '">' . $attachment->getName() . '</a><br/>'; } } $task->setBody($task_body); $savetask = $task->save(); if ($savetask && !is_error($savetask)) { $task->ready(); mysql_query("insert into actionrequests_to_tasklist (comment_id, user_id, type, object_id) values ('" . $this->active_comment->getId() . "', '" . $temp_user_id . "', 'Task', '" . $task->getId() . "')"); } //} } } //EOF:mod 20110719 if (!empty($subscribers_to_notify)) { //BOF:task_1260 /* //EOF:task_1260 mysql_query("update healingcrystals_assignments_action_request set is_fyi='0' where object_id='" . $active_object->getId() . "'"); if (!empty($subscribers_to_notify)){ $temp = $subscribers_to_notify; foreach($temp as $id){ $query = "select * from healingcrystals_assignments_action_request where object_id='" . $active_object->getId() . "' and user_id='" . $id . "'"; $result = mysql_query($query, $link); if (mysql_num_rows($result)){ mysql_query("update healingcrystals_assignments_action_request set is_fyi='1' where user_id='" . $id . "' and object_id='" . $active_object->getId() . "'"); } else { mysql_query("insert into healingcrystals_assignments_action_request (user_id, object_id, is_fyi) values ('" . $id . "', '" . $active_object->getId() . "', '1')"); } } } mysql_query("delete from healingcrystals_assignments_action_request where object_id='" . $active_object->getId() . "' and is_action_request='0' and is_fyi='0'"); //BOF:task_1260 */ foreach ($subscribers_to_notify as $id) { $query = "select * from healingcrystals_assignments_action_request where comment_id='" . $this->active_comment->getId() . "' and selected_by_user_id='" . $this->logged_user->getId() . "' and user_id='" . $id . "'"; $result = mysql_query($query); if (mysql_num_rows($result)) { $query = "update healingcrystals_assignments_action_request set is_fyi='1' where comment_id='" . $this->active_comment->getId() . "' and selected_by_user_id='" . $this->logged_user->getId() . "' and user_id='" . $id . "'"; mysql_query($query); } else { $query = "insert into healingcrystals_assignments_action_request (user_id, is_action_request, is_fyi, selected_by_user_id, comment_id, date_added) values ('" . $id . "', '0', '1', '" . $this->logged_user->getId() . "', '" . $this->active_comment->getId() . "', now())"; mysql_query($query); } } //EOF:task_1260 } //shawn wants to fire emails for only action request users and not for FYI users // for this, $subscribers_to_notify is set to $action_request_user_id, which will // take care of any assignments that were made above the code : 22-MAR-2011 //BOF:mod 20110623 $fyi_users = $subscribers_to_notify; $fyi_to = ''; //EOF:mod 20110623 $subscribers_to_notify = $action_request_user_id; //BOF:mod $email_to_user_ids = array_var($comment_data, 'email'); $emailed_to = ''; foreach ($email_to_user_ids as $user_id) { $temp_user = new User($user_id); //BOF:mod 20130429 /* //EOF:mod 20130429 $emailed_to .= $temp_user->getName() . ', '; //BOF:mod 20130429 */ //EOF:mod 20130429 $query = "select * from healingcrystals_assignments_action_request where comment_id='" . $this->active_comment->getId() . "' and selected_by_user_id='" . $this->logged_user->getId() . "' and user_id='" . $user_id . "'"; $result = mysql_query($query); if (mysql_num_rows($result)) { $query = "update healingcrystals_assignments_action_request set marked_for_email='1' where comment_id='" . $this->active_comment->getId() . "' and selected_by_user_id='" . $this->logged_user->getId() . "' and user_id='" . $user_id . "'"; mysql_query($query); } else { $query = "insert into healingcrystals_assignments_action_request (user_id, is_action_request, is_fyi, marked_for_email, selected_by_user_id, comment_id, date_added) values ('" . $user_id . "', '0', '0', '1', '" . $this->logged_user->getId() . "', '" . $this->active_comment->getId() . "', now())"; mysql_query($query); } } reset($email_to_user_ids); //EOF:mod if (!empty($subscribers_to_notify)) { //$subscribers_to_notify = implode(',', $subscribers_to_notify); //mysql_query("insert into healingcrystals_testing (query, fired_at) values ('" . $subscribers_to_notify . "', now())"); $notified_to = ''; //$subscribers = explode(',', $subscribers_to_notify); $subscribers = $subscribers_to_notify; $all_subscribers = $active_object->getSubscribers(); $excluded = array(); $included = array(); //$excluded_temp = array(); //$included_temp = array(); $subscribers_name = ''; foreach ($all_subscribers as $reg_subscriber) { $subscribers_name .= $reg_subscriber->getName() . "<br/>"; $subscriber_excluded = true; //if ($this->logged_user->getId()!=$reg_subscriber->getId()){ foreach ($subscribers as $subscriber_id) { $subscriber_id = trim($subscriber_id); if ($reg_subscriber->getId() == $subscriber_id) { $included[] = $reg_subscriber; //BOF:mod 20130429 /* //EOF:mod 20130429 $notified_to .= $reg_subscriber->getName() . ', '; //BOF:mod 20130429 */ //EOF:mod 20130429 //$included_temp[] = $reg_subscriber->getId(); $subscriber_excluded = false; //$subscribers_name .= $reg_subscriber->getName() . "<br/>"; break; } } //BOF:mod 20110623 foreach ($fyi_users as $fyi_user_id) { $fyi_user_id = trim($fyi_user_id); if ($reg_subscriber->getId() == $fyi_user_id) { //BOF:mod 20130429 /* //EOF:mod 20130429 $fyi_to .= $reg_subscriber->getName() . ', '; //BOF:mod 20130429 */ //EOF:mod 20130429 break; } } //EOF:mod 20110623 //} if ($subscriber_excluded) { $excluded[] = $reg_subscriber->getId(); //$excluded_temp[] = $reg_subscriber->getId(); } } //$link = mysql_connect(DB_HOST, DB_USER, DB_PASS); //mysql_select_db(DB_NAME); //mysql_query("insert into healingcrystals_testing (query, fired_at) values ('" . implode('|', $included_temp) . ' = ' . implode('|', $excluded_temp) . "', now())"); //mysql_close($link); //BOF:mod 20110517 //if (count($included)){ if (!$complete_parent_object && count($included)) { //EOF:mod 20110517 //BOF:mod 20110623 //$notified_to = '<br/><br/>Notification emailed to: ' . substr($notified_to, 0, -2); //$this->active_comment->setBody($this->active_comment->getBody() . $notified_to . $fyi_to); //BOF:mod 20130429 /* //EOF:mod 20130429 if (!empty($notified_to)){ $notified_to = '<br/><br/>Action Request marked to: ' . substr($notified_to, 0, -2); } if (!empty($fyi_to)){ $fyi_to = (empty($notified_to) ? '<br/><br/>' : '<br/>') . 'FYI Comment marked to: ' . substr($fyi_to, 0, -2); } if (!empty($emailed_to)){ $emailed_to = (empty($notified_to) && empty($fyi_to) ? '<br/><br/>' : '<br/>') . 'Email sent to: ' . substr($emailed_to, 0, -2); } $this->active_comment->setBody($this->active_comment->getBody() . $notified_to . $fyi_to . $emailed_to); //EOF:mod 20110623 $this->active_comment->save(); //BOF:mod 20130429 */ //EOF:mod 20130429 //BOF:mod 20110720 ticketid246 /* //EOF:mod 20110720 ticketid246 $created_by = $this->active_comment->getCreatedBy(); $parent = $active_object; $parent->sendToSubscribers('resources/new_comment', array( 'comment_body' => $this->active_comment->getFormattedBody(), 'comment_url' => $this->active_comment->getViewUrl(), 'created_by_url' => $created_by->getViewUrl(), 'created_by_name' => $created_by->getDisplayName(), 'subscribers_name' => "<br/><br/>-- SET NOTIFICATIONS --<br/>" . $subscribers_name . "<br/><br/>", 'comment_id' => $this->active_comment->getId(), ), $excluded, $parent); //BOF:mod 20110720 ticketid246 */ //EOF:mod 20110720 ticketid246 /*$created_by = $this->active_comment->getCreatedBy(); $variables = array('owner_company_name' => get_owner_company(), 'project_name' => $this->active_project->getName(), 'project_url' => $this->active_project->getOverviewUrl(), 'object_type' => $this->active_comment->getVerboseType(), 'object_name' => $this->active_comment->getName(), 'comment_body' => $this->active_comment->getFormattedBody(), 'comment_url' => $this->active_comment->getViewUrl(), 'created_by_url' => $created_by->getViewUrl(), 'created_by_name' => $created_by->getDisplayName(),); ApplicationMailer::send($users, 'resources/new_comment', $variables, $this->active_milestone);*/ } } elseif (!empty($fyi_users)) { $all_subscribers = $active_object->getSubscribers(); foreach ($all_subscribers as $reg_subscriber) { foreach ($fyi_users as $fyi_user_id) { $fyi_user_id = trim($fyi_user_id); if ($reg_subscriber->getId() == $fyi_user_id) { $fyi_to .= $reg_subscriber->getName() . ', '; break; } } } /*$fyi_to = '<br/><br/>FYI Comment marked to: ' . substr($fyi_to, 0, -2); if (!empty($emailed_to)){ $emailed_to = (empty($fyi_to) ? '<br/><br/>' : '<br/>') . 'Email sent to: ' . substr($emailed_to, 0, -2); } $this->active_comment->setBody($this->active_comment->getBody() . $fyi_to . $emailed_to); $this->active_comment->save();*/ } elseif (!empty($email_to_user_ids)) { /*$emailed_to = '<br/><br/>Email sent to: ' . substr($emailed_to, 0, -2); $this->active_comment->setBody($this->active_comment->getBody() . $emailed_to); $this->active_comment->save();*/ } if (count($email_to_user_ids)) { $users = array(); foreach ($email_to_user_ids as $user_id) { if ($user_id != $this->logged_user->getId()) { $users[] = new User($user_id); } } $created_by = $this->active_comment->getCreatedBy(); $variables = array('owner_company_name' => get_owner_company(), 'project_name' => $this->active_project->getName(), 'project_url' => $this->active_project->getOverviewUrl(), 'object_type' => $this->active_comment->getVerboseType(), 'object_name' => $this->active_comment->getName(), 'object_body' => $this->active_comment->getFormattedBody(), 'object_url' => $this->active_comment->getViewUrl(), 'comment_body' => $this->active_comment->getFormattedBody(), 'comment_url' => $this->active_comment->getViewUrl(), 'created_by_url' => $created_by->getViewUrl(), 'created_by_name' => $created_by->getDisplayName(), 'details_body' => '', 'comment_id' => $this->active_comment->getId()); //BOF:mod 20111101 /* //EOF:mod 20111101 ApplicationMailer::send($users, 'resources/new_comment', $variables, $this->active_milestone); //BOF:mod 20111101 */ $parent_id = $this->active_comment->getParentId(); $parent_type = $this->active_comment->getParentType(); $parent_obj = new $parent_type($parent_id); $attachments = null; $object_attachments = $this->active_comment->getAttachments(); if ($object_attachments) { $attachments = array(); foreach ($object_attachments as $object_attachment) { $attachments[] = array('path' => $object_attachment->getFilePath(), 'name' => $object_attachment->getName(), 'mime_type' => $object_attachment->getMimeType()); } } ApplicationMailer::send($users, 'resources/new_comment', $variables, $parent_obj, $attachments); //EOF:mod 20111101 } //BOF:mod 20121030 $modify_comments_sorting = false; $reply_to_comment_id = $this->request->post('reply_to_comment_id'); if (!empty($reply_to_comment_id)) { $sql_data = array('integer_field_2' => $reply_to_comment_id); Comments::update($sql_data, "id='" . $this->active_comment->getId() . "'", TABLE_PREFIX . 'project_objects'); //$modify_comments_sorting = true; } //$count = 0; /*$link = mysql_connect(DB_HOST, DB_USER, DB_PASS); mysql_select_db(DB_NAME); $sql = "select * from " . TABLE_PREFIX . "project_objects where parent_id='" . $this->active_comment->getParentId() . "' and parent_type='" . $this->active_comment->getParentType() . "' and type='Comment' and (position is null or position='0')"; $result = mysql_query($sql, $link); if (!mysql_num_rows($result) ){ $sql = "select max(position) as count from " . TABLE_PREFIX . "project_objects where parent_id='" . $this->active_comment->getParentId() . "' and parent_type='" . $this->active_comment->getParentType() . "' and type='Comment'"; $result = mysql_query($sql, $link); $info = mysql_fetch_assoc($result); $count = $info['count']; $sql_data = array('position' => ++$count); Comments::update($sql_data, "id='" . $this->active_comment->getId() . "'", TABLE_PREFIX . 'project_objects'); } else { $modify_comments_sorting = true; } mysql_close($link);*/ //if ($modify_comments_sorting) $this->modify_comments_sorting($count); //EOF:mod 20121030 if ($this->request->isApiCall()) { $this->serveData($this->active_comment, 'comment'); } else { flash_success('Comment successfully posted'); //$this->redirectToUrl($this->active_comment->getRealViewUrl()); $this->redirectToUrl($this->active_comment->getParent()->getViewUrl()); } // if } else { db_rollback(); if ($this->request->isApiCall()) { $this->serveData($save); } else { $this->smarty->assign('errors', $save); } // if } // if } else { if ($this->request->isApiCall()) { $this->httpError(HTTP_ERR_BAD_REQUEST, null, true, true); } // if } // if }
function restore_user() { $user = Contacts::findById(get_id()); if (!($user instanceof Contact && $user->isUser())) { flash_error(lang('user dnx')); ajx_current("empty"); return; } if (!$user->canDelete(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } try { DB::beginWork(); $user->setDisabled(false); $user->unarchive(); ApplicationLogs::createLog($user, ApplicationLogs::ACTION_UNTRASH); $ret = null; Hook::fire("user_restored", $user, $ret); DB::commit(); flash_success('success delete user'); ajx_current("reload"); } catch (Exception $e) { flash_error($e->getMessage()); DB::rollback(); ajx_current("empty"); } }
/** * Delete locale logo * * @param void * @return null */ function delete_logo() { $locale = I18nLocales::findById(get_id()); if (!$locale instanceof I18nLocale) { flash_error(lang('locale dnx')); $this->redirectToReferer(get_url('i18n', 'index')); } // if if (!$locale->canEdit(logged_user())) { flash_error(lang('no access permissions')); $this->redirectTo('i18n', 'index'); } // if try { DB::beginWork(); $locale->deleteLogo(); $locale->save(); ApplicationLogs::createLog($locale, 0, ApplicationLogs::ACTION_EDIT); DB::commit(); flash_success(lang('success delete logo')); } catch (Exception $e) { DB::rollback(); flash_error(lang('error delete logo', $e)); } // try $this->redirectToUrl($locale->getEditLogoUrl()); }
function mass_update() { if ($this->request->isSubmitted()) { $action = $this->request->post('with_selected'); if (trim($action) == '') { flash_error('Please select what you want to do with selected milestones'); $this->redirectToReferer($this->smarty->get_template_vars('milestoness_url')); } // if $milestone_ids = $this->request->post('milestones'); $milestones = Milestones::findByIds($milestone_ids, STATE_VISIBLE, $this->logged_user->getVisibility()); $updated = 0; if (is_foreachable($milestones)) { // Complete selected milestones if ($action == 'complete') { $message = lang(':count milestones completed'); //BOF:mod 20110617 //BOF:mod 20120917 (reversed by shawn) /* //EOF:mod 20120917 $warning = ''; foreach($milestones as $milestone) { if($milestone->isOpen() && $milestone->canChangeCompleteStatus($this->logged_user)) { $responsible_assignee = $milestone->getResponsibleAssignee(); $created_by_id = $milestone->getCreatedById(); $project_leader = $this->active_project->getLeaderId(); if ( (!is_null($responsible_assignee) && $responsible_assignee->getId()==$this->logged_user->getId()) || $created_by_id==$this->logged_user->getId() || $project_leader==$this->logged_user->getId() || $this->logged_user->isAdministrator() ){ $warning .= ''; } else { $warning .= '"' . $milestone->getName() . '", '; } } } if (!empty($warning)){ $temp = new User(!empty($created_by_id) ? $created_by_id : $project_leader); $warning = 'Project ' . substr($warning, 0, -2) . ' cannot be closed at this time. Please send message to ' . $temp->getName() . ' to close this ticket.'; unset($temp); flash_error($warning, null, true); $this->redirectToReferer($this->smarty->get_template_vars('milestones_url')); } else { //BOF:mod 20120917 (reversed by shawn) */ //EOF:mod 20120917 //EOF:mod 20110617 foreach ($milestones as $milestone) { if ($milestone->isOpen() && $milestone->canChangeCompleteStatus($this->logged_user)) { $complete = $milestone->complete($this->logged_user); if ($complete && !is_error($complete)) { $updated++; } // if } // if } // foreach $this->redirectToReferer($this->smarty->get_template_vars('milestoness_url')); //BOF:mod 20110617 //BOF:mod 20120917 (reversed by shawn) /* //EOF:mod 20120917 } //BOF:mod 20120917 (reversed by shawn) */ //EOF:mod 20120917 //EOF:mod 20110617 // Open selected milestones } elseif ($action == 'open') { $message = lang(':count milestones opened'); foreach ($milestones as $milestone) { if ($milestone->isCompleted() && $milestone->canChangeCompleteStatus($this->logged_user)) { $open = $milestone->open($this->logged_user); if ($open && !is_error($open)) { $updated++; } // if } // if } // foreach $this->redirectToReferer($this->smarty->get_template_vars('milestoness_url')); // Mark object as starred } elseif ($action == 'star') { $message = lang(':count milestones starred'); foreach ($milestones as $milestone) { $star = $milestone->star($this->logged_user); if ($star && !is_error($star)) { $updated++; } // if } // foreach $this->redirectToReferer($this->smarty->get_template_vars('milestoness_url')); // Unstar objects } elseif ($action == 'unstar') { $message = lang(':count milestones unstarred'); foreach ($milestones as $milestone) { $unstar = $milestone->unstar($this->logged_user); if ($unstar && !is_error($unstar)) { $updated++; } // if } // foreach $this->redirectToReferer($this->smarty->get_template_vars('milestoness_url')); // Move selected objects to Trash } elseif ($action == 'trash') { $message = lang(':count milestones moved to Trash'); foreach ($milestones as $milestone) { if ($milestone->canDelete($this->logged_user)) { $delete = $milestone->moveToTrash(); if ($delete && !is_error($delete)) { $updated++; } // if } // if } // foreach $this->redirectToReferer($this->smarty->get_template_vars('milestoness_url')); // Set a selected priority } elseif (str_starts_with($action, 'set_priority')) { $priority = (int) substr($action, 13); $message = lang(':count milestones updated'); foreach ($milestones as $milestone) { if ($milestone->canEdit($this->logged_user)) { $milestone->setPriority($priority); $save = $milestone->save(); if ($save && !is_error($save)) { $updated++; } // if } // if } // foreach $this->redirectToReferer($this->smarty->get_template_vars('milestoness_url')); // Set visibility } elseif (str_starts_with($action, 'set_visibility')) { $visibility = (int) substr($action, 15); $message = lang(':count milestones updated'); foreach ($milestones as $milestone) { if ($milestone->canEdit($this->logged_user)) { $milestone->setVisibility($visibility); $save = $milestone->save(); if ($save && !is_error($save)) { $updated++; } // if } // if } // foreach $this->redirectToReferer($this->smarty->get_template_vars('milestoness_url')); // Move selected milestones to selected category } elseif (str_starts_with($action, 'move_to_category')) { if ($action == 'move_to_category') { $category_id = null; } else { $category_id = (int) substr($action, 17); } // if //$category = $category_id ? Categories::findById($category_id) : null; $message = lang(':count milestones updated'); foreach ($milestones as $milestone) { if ($milestone->canEdit($this->logged_user)) { $milestone->setCategoryId($category_id); $save = $milestone->save(); if ($save && !is_error($save)) { $updated++; } // if } // if } // foreach $this->redirectToReferer($this->smarty->get_template_vars('milestoness_url')); } else { $this->httpError(HTTP_ERR_BAD_REQUEST); } // if } else { flash_error('Please select milestones that you would like to update'); $this->redirectToReferer($this->smarty->get_template_vars('milestones_url')); } // if } else { $this->httpError(HTTP_ERR_BAD_REQUEST); } }