/** * Shortcut function for retrieving single lang value * * @access public * @param string $name * @return string */ function lang($name) { // Get function arguments and remove first one. $args = func_get_args(); if (is_array($args)) { array_shift($args); } // if // Get value and if we have NULL done! if (plugin_active('i18n')) { $value = lang_from_db($name); } else { $value = Localization::instance()->lang($name); } if (is_null($value)) { return $value; } // if // We have args? Replace all %s with arguments if (is_array($args) && count($args)) { foreach ($args as $arg) { $value = str_replace_first('%s', $arg, $value); } // foreach } // if // Done here... return $value; }
function checkEventManager() { $events_manager_actived = plugin_active('events-manager/events-manager.php'); (bool) $events_manager_actived; if ($events_manager_actived) { $notice = null; } else { $notice = __("Event Manager Importer : Event Manager is not enabled. Please enable it before our plugin.", "emi"); } parent::set_notice($notice); }
function emiStart() { if (is_admin() && plugin_active('events-manager/events-manager.php')) { add_action('wp_ajax_get_file_info', 'get_file_info'); add_action('wp_ajax_nopriv_get_file_info', 'get_file_info'); upload_create(); $EmiController = new EmiController(); } else { if (!plugin_active('events-manager/events-manager.php')) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; deactivate_plugins('wp-events-manager-importer/emi.php'); } } }
/** * Renders attachment control based on Object type * * @param void * @return string */ function renderControl($control_name) { switch ($this->getRelObjectManager()) { case 'Companies': return select_company($control_name, $this->getRelObjectId(), array('class' => 'combobox')); break; case 'Contacts': return select_contact($control_name, $this->getRelObjectId(), null, array('class' => 'combobox')); break; case 'ProjectFiles': if (plugin_active('files')) { return select_project_file($control_name, active_project(), $this->getRelObjectId(), null, array('class' => 'combobox')); } return ''; break; case 'ProjectMessages': return select_message($control_name, active_project(), $this->getRelObjectId(), array('class' => 'combobox')); break; case 'ProjectMilestones': return select_milestone($control_name, active_project(), $this->getRelObjectId(), array('class' => 'combobox')); break; case 'ProjectTasks': break; case 'ProjectTaskLists': return select_task_list($control_name, active_project(), $this->getRelObjectId(), array('class' => 'combobox')); break; case 'ProjectTickets': if (plugin_active('tickets')) { return select_ticket($control_name, active_project(), $this->getRelObjectId(), array('class' => 'combobox')); } return ''; break; default: return ''; break; } // switch }
?> <div> <?php echo label_tag(lang('projects copy links'), 'projectFormCopyLinks'); ?> <?php echo checkbox_field('project[copy_links]', true, array_var($project_data, 'copy_links'), array('id' => 'projectFormCopyLinks')); ?> </div> <?php } // if ?> <?php if (plugin_active('wiki')) { ?> <div> <?php echo label_tag(lang('projects copy pages'), 'projectFormCopyPages'); ?> <?php echo checkbox_field('project[copy_pages]', true, array_var($project_data, 'copy_pages'), array('id' => 'projectFormCopyPages')); ?> </div> <?php } // if ?> <?php
/** * Clear all folders * * @param void * @return null */ private function clearFolders() { if(!plugin_active('files')) { return null; } $folders = $this->getFolders(); if (is_array($folders)) { foreach ($folders as $folder) { $folder->delete(); } // foreach } // if } // clearFolders
/** * Edit locale * * @param void * @return null */ function edit_locale() { $locale = I18nLocales::findById(get_id()); if (!$locale instanceof I18nLocale) { flash_error(lang('locale dnx')); $this->redirectTo('i18n', 'index'); } // if if (!$locale->canEdit(logged_user())) { flash_error(lang('no access permissions')); $this->redirectTo('i18n', 'index'); } // if $this->setTemplate('edit_locale'); $locale_data = array_var($_POST, 'locale'); if (!is_array($locale_data)) { $tag_names = ''; //$tag_names = plugin_active('tags') ? $locale->getTagNames() : ''; $locale_data = array('name' => $locale->getName(), 'description' => $locale->getDescription(), 'language_code' => $locale->getLanguageCode(), 'country_code' => $locale->getCountryCode(), 'editor_id' => $locale->getEditorId(), 'translation_url' => $locale->getTranslationUrl(), 'tags' => is_array($tag_names) ? implode(', ', $tag_names) : ''); // array } // if //tpl_assign('locale_data', $locale_data); //tpl_assign('locale', $locale); if (is_array(array_var($_POST, 'locale'))) { $locale->setFromAttributes($locale_data); try { DB::beginWork(); $locale->save(); ApplicationLogs::createLog($locale, 0, ApplicationLogs::ACTION_EDIT); if (plugin_active('tags')) { // tags currently at project level and locale NOT project level //$locale->setTagsFromCSV($locale_data['tags']); } DB::commit(); flash_success(lang('success edit locale')); $this->redirectTo('i18n', 'index'); } catch (Exception $e) { DB::rollback(); tpl_assign('error', $e); } // try } tpl_assign('locale', $locale); tpl_assign('locale_data', $locale_data); }
<a href="<?php echo get_url('page_attachment', 'add_attachment', array('page_name' => 'project_overview', 'rel_object_manager' => 'ProjectMessages', 'order' => $counter, 'redirect_to' => get_url('project', 'edit', null, null, true)), null, true); ?> "><?php echo lang('add message'); ?> </a> | <a href="<?php echo get_url('page_attachment', 'add_attachment', array('page_name' => 'project_overview', 'rel_object_manager' => 'ProjectMilestones', 'order' => $counter, 'redirect_to' => get_url('project', 'edit', null, null, true)), null, true); ?> "><?php echo lang('add milestone'); ?> </a> | <?php if (plugin_active('tickets')) { ?> <a href="<?php echo get_url('page_attachment', 'add_attachment', array('page_name' => 'project_overview', 'rel_object_manager' => 'ProjectTickets', 'order' => $counter, 'redirect_to' => get_url('project', 'edit', null, null, true)), null, true); ?> "><?php echo lang('add ticket'); ?> </a> <?php } ?> </div> <?php } // foreach
/** * Render the tags of a specific object * * @param ProjectDataObject $object * @return string */ function render_object_tags(ProjectDataObject $object) { if (plugin_active('tags')) { tpl_assign('object', $object); //tpl_assign('tags', $object->getTags()); return tpl_fetch(get_template_path('object_tags', 'tags')); } return ''; }
<?php trace(__FILE__, 'start'); set_page_title(lang('view task')); project_tabbed_navigation('tasks'); project_crumbs(array(array(lang('tasks'), get_url('task')), array($task_list->getName(), $task_list->getViewUrl()), array(lang('view task')))); $options = array(); if ($task->canEdit(logged_user())) { $options[] = '<a href="' . $task->getEditUrl() . '">' . lang('edit') . '</a>'; } if ($task->canDelete(logged_user())) { $options[] = '<a href="' . $task->getDeleteUrl() . '">' . lang('delete') . '</a>'; } if (plugin_active('time')) { if (ProjectTime::canAdd(logged_user(), active_project())) { $options[] = '<a href="' . get_url('time', 'add', array('task' => $task->getId())) . '">' . lang('add time') . '</a>'; } } if ($task->canChangeStatus(logged_user())) { if ($task->isOpen()) { $options[] = '<a href="' . $task->getCompleteUrl() . '">' . lang('mark task as completed') . '</a>'; } else { $options[] = '<a href="' . $task->getOpenUrl() . '">' . lang('open task') . '</a>'; } // if } // if ?> <div id="taskDetails" class="block"> <div class="header"><?php
/** * Edit file * * @access public * @param void * @return null */ function edit_file() { $this->setTemplate('add_file'); $file = ProjectFiles::findById(get_id()); if (!$file instanceof ProjectFile) { flash_error(lang('file dnx')); $this->redirectToReferer(get_url('files')); } // if if (!$file->canEdit(logged_user())) { flash_error(lang('no access permissions')); $this->redirectToReferer(get_url('files')); } // if $file_data = array_var($_POST, 'file'); if (!is_array($file_data)) { $tag_names = plugin_active('tags') ? $file->getTagNames() : ''; $file_data = array('folder_id' => $file->getFolderId(), 'description' => $file->getDescription(), 'is_private' => $file->getIsPrivate(), 'is_important' => $file->getIsImportant(), 'comments_enabled' => $file->getCommentsEnabled(), 'anonymous_comments_enabled' => $file->getAnonymousCommentsEnabled(), 'tags' => is_array($tag_names) && count($tag_names) ? implode(', ', $tag_names) : ''); // array } // if tpl_assign('file', $file); tpl_assign('file_data', $file_data); if (is_array(array_var($_POST, 'file'))) { try { $old_is_private = $file->isPrivate(); $old_is_important = $file->getIsImportant(); $old_comments_enabled = $file->getCommentsEnabled(); $old_anonymous_comments_enabled = $file->getAnonymousCommentsEnabled(); DB::beginWork(); $handle_file = array_var($file_data, 'update_file') == 'checked'; // change file? $post_revision = $handle_file && array_var($file_data, 'version_file_change') == 'checked'; // post revision? $revision_comment = $post_revision ? trim(array_var($file_data, 'revision_comment')) : ''; // user comment? $file->setFromAttributes($file_data); if (!logged_user()->isMemberOfOwnerCompany()) { $file->setIsPrivate($old_is_private); $file->setIsImportant($old_is_important); $file->setCommentsEnabled($old_comments_enabled); $file->setAnonymousCommentsEnabled($old_anonymous_comments_enabled); } // if $file->save(); if (plugin_active('tags')) { $file->setTagsFromCSV(array_var($file_data, 'tags')); } $msg_name = basename($file->getFilename()); if ($handle_file) { $file->handleUploadedFile(array_var($_FILES, 'file_file'), $post_revision, $revision_comment); $msg_name .= '(' . ')'; } // if ApplicationLogs::createLog($file, active_project(), ApplicationLogs::ACTION_EDIT); DB::commit(); flash_success(lang('success edit file', $msg_name)); $this->redirectToUrl($file->getDetailsUrl()); } catch (Exception $e) { //@unlink($file->getFilePath()); DB::rollback(); tpl_assign('error', $e); } // try } // if }
<div class="private" title="<?php echo lang('private task list') ?>"> <span><?php echo lang('private task list') ?></span> </div> <?php endif ?> </div> <?php if (!is_null($task_list->getDueDate())) : ?> <div class="dueDate"><span><?php echo lang('due date') ?>:</span> <?php echo ($task_list->getDueDate()->getYear() > DateTimeValueLib::now()->getYear()) ? format_date($task_list->getDueDate(), null, 0) : format_descriptive_date($task_list->getDueDate(), 0) ?></div> <?php endif ?> <?php if ($task_list->getDescription()): ?> <div class="desc"><?php echo (do_textile($task_list->getDescription())) ?></div> <?php endif ?> <?php if (plugin_active('tags')): ?> <div class="taskListTags"><span><?php echo lang('tags') ?>:</span> <?php echo project_object_tags($task_list, $task_list->getProject()) ?></div> <?php endif ?> <?php if (count($task_list_options)): ?> <div class="options"><?php echo implode(' | ', $task_list_options) ?></div> <?php endif ?> <?php if (is_array($task_list->getOpenTasks())): ?> <div class="openTasks"> <ul id="<?php echo $task_list->getId() ?>"><!--table class="blank"--> <?php foreach ($task_list->getOpenTasks() as $task): ?> <li id="<?php echo $task->getId() ?>" class="<?php odd_even_class($task_list_ln) ?>"><!--tr class="<?php odd_even_class($task_list_ln); ?>"--> <!-- Task text and options --> <!--td class="taskText"--> <div class="task-text">
/** * Edit a wiki page * * @return void */ function edit() { if (!WikiPage::canEdit(logged_user())) { flash_error(lang('no wiki page edit permissions')); $this->redirectToReferer(get_url('wiki')); } //Get the page from the url params $page = Wiki::getPageById(get_id(), active_project()); if (!instance_of($page, 'WikiPage')) { //If the page doesn't exist, redirect to wiki index flash_error(lang('wiki page dnx')); $this->redirectToReferer(get_url('wiki')); } // if //Check that the user can edit this entry if (!$page->canEdit(logged_user())) { flash_error(lang('no access permissions')); $this->redirectTo(get_url('wiki')); } // if // Check that the page isn't locked if ($page->isLocked() && !$page->canUnlock(logged_user())) { flash_error(lang('wiki page locked by', $page->getLockedByUser()->getUsername())); $this->redirectToUrl($page->getViewUrl()); } // if //Here we will edit a wiki page $preview = false; $data = array_var($_POST, 'wiki', false); if (false !== $data) { $preview = array_key_exists('preview', $data); } if (!$preview && $data) { //if(null !== ($data = array_var($_POST, 'wiki'))){ //If we have received data //Make a new revision $revision = $page->makeRevision(); $revision->setFromAttributes($data); $page->setProjectIndex($data['project_index']); $page->setProjectSidebar($data['project_sidebar']); $page->setPublish($data['publish']); $page->setParentId($data['parent_id']); // Check to see if we want to lock this page if (isset($data['locked'])) { if ($data['locked'] == 1 && $page->canLock(logged_user()) && !$page->isLocked()) { // If we want to lock this page and the user has permissions to lock it, and the page is not already locked $page->setLocked(true); $page->setLockedById(logged_user()->getId()); $page->setLockedOn(DateTimeValueLib::now()); } elseif ($data['locked'] == 0 & $page->canUnlock(logged_user()) && $page->isLocked()) { // Else if we want to unlock the page, and the user is allowed to, and the page is locked $page->setLocked(false); } // if } // if //Set the users ID $revision->setCreatedById(logged_user()->getId()); try { //Start the transaction DB::beginWork(); //Save the page and create revision //The page will make sure that the revision's project and page Id are correct $page->save(); ApplicationLogs::createLog($page, active_project(), ApplicationLogs::ACTION_EDIT); if (plugin_active('tags')) { //Set the tags $page->setTagsFromCSV($data['tags']); } //Commit changes DB::commit(); flash_success(lang('success edit wiki page')); //Redirect to the page we just created $this->redirectToUrl($page->getViewUrl()); } catch (Exception $e) { //Get rid of any Db changes we've made DB::rollback(); //Assign the problem to the template so we can tell the user tpl_assign('error', $e); } //try } else { if (array_var($_GET, 'revision')) { //If we want to make a new revision based off a revision $revision = $page->getRevision($_GET['revision']); } else { $revision = $page->getLatestRevision(); } } //if if (!$data) { // there was no input POSTed $data['content'] = $revision->getContent(); } $data['preview_content'] = do_textile($data['content']); //Assign revision object tpl_assign('revision', $revision); tpl_assign('data', $data); //Assign the page object tpl_assign('page', $page); $tag_names = plugin_active('tags') ? $page->getTagNames() : ''; $tags = is_array($tag_names) ? implode(', ', $tag_names) : ''; tpl_assign('tags', $tags); //Set the template $this->setTemplate('edit'); $this->setSidebar(get_template_path('textile_help_sidebar')); }
/** * Display time management tool * * @access public * @param void * @return null */ function time() { if (plugin_active('time')) { tpl_assign('projects', logged_user()->getProjects()); tpl_assign('users', owner_company()->getUsers()); $status = array_var($_GET, 'status') ? array_var($_GET, 'status') : 0; $times = ProjectTimes::getTimeByStatus($status); $redirect_to = array_var($_GET, 'redirect_to'); if ($redirect_to == '') { $redirect_to = get_url('administration', 'time', array('status' => $status)); $redirect_to = str_replace('&', '&', trim($redirect_to)); } // if tpl_assign('times', $times); tpl_assign('redirect_to', $redirect_to); } else { $this->redirectTo('administration'); } }
/** * Edit project link * * @param void * @return null */ function edit_link() { $project_link = ProjectLinks::findById(get_id()); if (!ProjectLink::canEdit(logged_user())) { flash_error(lang('no access permissions')); $this->redirectTo('links','index'); } // if if (!($project_link instanceof ProjectLink)) { flash_error(lang('project link dnx')); $this->redirectTo('links'); } // if $this->setTemplate('edit_link'); $this->addHelper('files', 'files'); $project_link_data = array_var($_POST, 'project_link'); if (!is_array($project_link_data)) { $tag_names = plugin_active('tags') ? $project_link->getTagNames() : ''; $project_link_data = array( 'title' => $project_link->getTitle(), 'url' => $project_link->getUrl(), 'description' => $project_link->getDescription(), 'folder_id' => $project_link->getFolderId(), 'tags' => is_array($tag_names) ? implode(', ', $tag_names) : '', ); // array } // if tpl_assign('project_link_data', $project_link_data); tpl_assign('project_link', $project_link); if (is_array(array_var($_POST, 'project_link'))) { $project_link->setFromAttributes($project_link_data); $project_link->setProjectId(active_project()->getId()); try { DB::beginWork(); $project_link->save(); ApplicationLogs::createLog($project_link, active_project(), ApplicationLogs::ACTION_EDIT); if (plugin_active('tags')) { $project_link->setTagsFromCSV($project_link_data['tags']); } DB::commit(); flash_success(lang('success edit link')); $this->redirectTo('links'); } catch(Exception $e) { DB::rollback(); tpl_assign('error', $e); } // try } tpl_assign('project_link', $project_link); tpl_assign('project_link_data', $project_link_data); } // edit_link
/** * Show and process edit milestone form * * @access public * @param void * @return null */ function edit() { $this->setTemplate('add_milestone'); $milestone = ProjectMilestones::findById(get_id()); if (!$milestone instanceof ProjectMilestone) { flash_error(lang('milestone dnx')); $this->redirectTo('milestone', 'index'); } // if if (!$milestone->canEdit(logged_user())) { flash_error(lang('no access permissions')); $this->redirectToReferer(get_url('milestone')); } $milestone_data = array_var($_POST, 'milestone'); if (!is_array($milestone_data)) { $tag_names = plugin_active('tags') ? $milestone->getTagNames() : ''; $milestone_data = array('name' => $milestone->getName(), 'due_date' => $milestone->getDueDate(), 'description' => $milestone->getDescription(), 'assigned_to' => $milestone->getAssignedToCompanyId() . ':' . $milestone->getAssignedToUserId(), 'tags' => is_array($tag_names) ? implode(', ', $tag_names) : '', 'is_private' => $milestone->isPrivate()); // array } // if tpl_assign('milestone_data', $milestone_data); tpl_assign('milestone', $milestone); if (is_array(array_var($_POST, 'milestone'))) { $old_owner = $milestone->getAssignedTo(); // remember the old owner if (isset($_POST['milestone_due_date'])) { $milestone_data['due_date'] = DateTimeValueLib::makeFromString($_POST['milestone_due_date']); } else { $milestone_data['due_date'] = DateTimeValueLib::make(0, 0, 0, array_var($_POST, 'milestone_due_date_month', 1), array_var($_POST, 'milestone_due_date_day', 1), array_var($_POST, 'milestone_due_date_year', 1970)); } //$milestone_data['due_date'] = DateTimeValueLib::make(0, 0, 0, array_var($_POST, 'milestone_due_date_month', 1), array_var($_POST, 'milestone_due_date_day', 1), array_var($_POST, 'milestone_due_date_year', 1970)); $assigned_to = explode(':', array_var($milestone_data, 'assigned_to', '')); $old_is_private = $milestone->isPrivate(); $milestone->setFromAttributes($milestone_data); if (!logged_user()->isMemberOfOwnerCompany()) { $milestone->setIsPrivate($old_is_private); } $milestone->setProjectId(active_project()->getId()); $milestone->setAssignedToCompanyId(array_var($assigned_to, 0, 0)); $milestone->setAssignedToUserId(array_var($assigned_to, 1, 0)); try { DB::beginWork(); $milestone->save(); if (plugin_active('tags')) { $milestone->setTagsFromCSV(array_var($milestone_data, 'tags')); } ApplicationLogs::createLog($milestone, active_project(), ApplicationLogs::ACTION_EDIT); DB::commit(); // If owner is changed send notification but don't break submission try { $new_owner = $milestone->getAssignedTo(); if (array_var($milestone_data, 'send_notification') == 'checked') { if ($old_owner instanceof User) { // We have a new owner and it is different than old owner if ($new_owner instanceof User && $new_owner->getId() != $old_owner->getId()) { Notifier::milestoneAssigned($milestone); } } else { // We have new owner if ($new_owner instanceof User) { Notifier::milestoneAssigned($milestone); } } // if } // if } catch (Exception $e) { } // try flash_success(lang('success edit milestone', $milestone->getName())); $this->redirectTo('milestone'); } catch (Exception $e) { DB::rollback(); tpl_assign('error', $e); } // try } // if }
/** * Call back function for ticket link * * @param mixed $matches * @return */ function replace_ticket_link_callback($matches) { if (!plugin_active('tickets')) { return null; } if (count($matches) < 2) { return null; } // if if (!logged_user()->isMemberOfOwnerCompany()) { $object = ProjectTickets::findOne(array('conditions' => array('`id` = ? AND `project_id` = ? AND `is_private` = 0 ', $matches[1], active_project()->getId()))); } else { $object = ProjectTickets::findOne(array('conditions' => array('`id` = ? AND `project_id` = ?', $matches[1], active_project()->getId()))); } // if if (!$object instanceof ProjectTicket) { return '<del>' . lang('invalid reference', $matches[0]) . '</del>'; } else { return '<a href="' . externalUrl($object->getViewUrl()) . '" title="' . lang('ticket') . '">' . $object->getTitle() . '</a>'; } // if }
/** * Edit a wiki page * * @return void */ function edit() { if (!WikiPage::canEdit(logged_user())) { flash_error(lang('no wiki page edit permissions')); $this->redirectToReferer(get_url('wiki')); } //Get the page from the url params $page = Wiki::getPageById(get_id(), active_project()); if (!instance_of($page, 'WikiPage')) { //If the page doesn't exist, redirect to wiki index flash_error(lang('wiki page dnx')); $this->redirectToReferer(get_url('wiki')); } // if //Check that the user can edit this entry if (!$page->canEdit(logged_user())) { flash_error(lang('no access permissions')); $this->redirectTo(); } // if //Here we will edit a wiki page if (null !== ($data = array_var($_POST, 'wiki'))) { //If we have received data //Make a new revision $revision = $page->makeRevision(); $revision->setFromAttributes($data); $page->setProjectIndex($data['project_index']); $page->setProjectSidebar($data['project_sidebar']); //Set the users ID $revision->setCreatedById(logged_user()->getId()); try { //Start the transaction DB::beginWork(); //Save the page and create revision //The page will make sure that the revision's project and page Id are correct $page->save(); ApplicationLogs::createLog($page, active_project(), ApplicationLogs::ACTION_EDIT); if (plugin_active('tags')) { //Set the tags $page->setTagsFromCSV($data['tags']); } //Commit changes DB::commit(); flash_success(lang('success edit wiki page')); //Redirect to the page we just created $this->redirectToUrl($page->getViewUrl()); } catch (Exception $e) { //Get rid of any Db changes we've made DB::rollback(); //Assign the problem to the template so we can tell the user tpl_assign('error', $e); } //try } else { if (array_var($_GET, 'revision')) { //If we want to make a new revision based off a revision $revision = $page->getRevision($_GET['revision']); } else { $revision = $page->getLatestRevision(); } } //if //Assign revision object tpl_assign('revision', $revision); //Assign the page object tpl_assign('page', $page); //Set the template $this->setTemplate('edit'); }
/** * Get project forms that are in relation with this message * * @param void * @return array */ function getRelatedForms() { trace(__FILE__, 'getRelatedForms()'); if (!plugin_active('form')) { return null; } if (is_null($this->related_forms)) { $this->related_forms = ProjectForms::findAll(array('conditions' => '`action` = ' . DB::escape(ProjectForm::ADD_COMMENT_ACTION) . ' AND `in_object_id` = ' . DB::escape($this->getId()), 'order' => '`order`')); // findAll } // if return $this->related_forms; }
/** * Shows weekly schedule in a calendar view * * @param void * @return null */ function weekly_schedule() { $this->addHelper('textile'); // Gets desired view 'detail', 'list' or 'calendar' // $view_type is from URL, Cookie or set to default: 'calendar' $view_type = array_var($_GET, 'view', Cookie::getValue('weeklyScheduleViewType', 'calendar')); $expiration = Cookie::getValue('remember' . TOKEN_COOKIE_NAME) ? REMEMBER_LOGIN_LIFETIME : null; Cookie::setValue('weeklyScheduleViewType', $view_type, $expiration); $monthYear = array_var($_GET, 'month'); if (!isset($monthYear) || trim($monthYear) == '' || preg_match('/^(\\d{4})(\\d{2})$/', $monthYear, $matches) == 0) { $year = gmdate('Y'); $month = gmdate('m'); } else { list(, $year, $month) = $matches; } // TODO make first day of week configurable $from_date = DateTimeValueLib::makeFromString('monday' . (date('w') == 1 ? '' : ' last week')); $to_date = $from_date->advance(60 * 60 * 24 * 7 * 3, false); // +3 weeks $upcoming_milestones = ProjectMilestones::getActiveMilestonesInPeriodByUser(logged_user(), $from_date, $to_date); $upcoming_tickets = array(); if (plugin_active('tickets')) { $upcoming_tickets = ProjectTickets::getOpenTicketsInPeriodByUser(logged_user(), $from_date, $to_date); } $active_projects = array(); $projects_index = array(); $counter = 1; if (is_array($upcoming_milestones)) { foreach ($upcoming_milestones as $milestone) { if (!isset($projects_index[$milestone->getProjectId()])) { $projects_index[$milestone->getProjectId()] = $counter; $active_projects[] = $milestone->getProject(); $counter++; } // if } // foreach } // if if (is_array($upcoming_tickets)) { foreach ($upcoming_tickets as $ticket) { if (!isset($projects_index[$ticket->getProjectId()])) { $projects_index[$ticket->getProjectId()] = $counter; $active_projects[] = $ticket->getProject(); $counter++; } // if } // foreach } // if tpl_assign('from_date', $from_date); tpl_assign('to_date', $to_date); tpl_assign('view_type', $view_type); tpl_assign('upcoming_tickets', $upcoming_tickets); tpl_assign('late_tickets', array()); // logged_user()->getLateTickets()); tpl_assign('upcoming_milestones', $upcoming_milestones); tpl_assign('late_milestones', array()); // logged_user()->getLateMilestones()); tpl_assign('projects', $active_projects); tpl_assign('projects_index', $projects_index); }
//$installation_root = config_option('installation_root', dirname($_SERVER['PHP_SELF']) ); $path = $_SERVER['PHP_SELF']; $path = substr($path, 0, strpos($path, 'index.php')); $installation_root = $path; define('ROOT_URL', $installation_root); // Init flash! Flash::instance(); $language = config_option('installation_base_language', 'en_us'); if (isset($_GET['language'])) { $_SESSION['language'] = $_GET['language']; $_GET['language'] = ''; } if (isset($_SESSION['language'])) { $language = $_SESSION['language']; } if (!plugin_active('i18n')) { Localization::instance()->loadSettings($language, ROOT . '/language'); } try { trace(__FILE__, 'CompanyWebsite::init()'); CompanyWebsite::init(); if (config_option('upgrade_check_enabled', false)) { VersionChecker::check(false); } // if if (config_option('file_storage_adapter', 'mysql') == FILE_STORAGE_FILE_SYSTEM) { trace(__FILE__, 'FileRepository::setBackend() - use file storage'); FileRepository::setBackend(new FileRepository_Backend_FileSystem(FILES_DIR)); } else { trace(__FILE__, 'FileRepository::setBackend() - use mysql storage'); FileRepository::setBackend(new FileRepository_Backend_MySQL(DB::connection()->getLink(), TABLE_PREFIX));
/** * * @access public * @param void * @return null */ function edit() { $this->setTemplate('add_contact'); $contact = Contacts::findById(get_id()); if (!$contact instanceof Contact) { flash_error(lang('contact dnx')); $this->redirectTo('dashboard', 'contacts'); } // if if (!$contact->canEdit(logged_user())) { flash_error(lang('no access permissions')); $this->redirectTo('dashboard', 'contacts'); } // if $im_types = ImTypes::findAll(array('order' => '`id`')); $contact_data = array_var($_POST, 'contact'); $company = $contact->getCompany(); if (!is_array($contact_data)) { $tag_names = null; if (plugin_active('tags')) { $tag_names = $contact->getTagNames(); } $contact_data = array('display_name' => $contact->getDisplayName(), 'first_name' => $contact->getFirstName(), 'middle_name' => $contact->getMiddleName(), 'last_name' => $contact->getLastName(), 'company_id' => $contact->getCompanyId(), 'title' => $contact->getTitle(), 'email' => $contact->getEmail(), 'timezone' => $contact->getTimezone(), 'office_number' => $contact->getOfficeNumber(), 'fax_number' => $contact->getFaxNumber(), 'mobile_number' => $contact->getMobileNumber(), 'home_number' => $contact->getHomeNumber(), 'food_preferences' => $contact->getFoodPreferences(), 'license_plate' => $contact->getLicensePlate(), 'location_details' => $contact->getLocationDetails(), 'department_details' => $contact->getDepartmentDetails(), 'use_gravatar' => $contact->getUseGravatar(), 'tags' => is_array($tag_names) ? implode(', ', $tag_names) : ''); // array if (is_array($im_types)) { foreach ($im_types as $im_type) { $contact_data['im_' . $im_type->getId()] = $contact->getImValue($im_type); } // forech } // if $default_im = $contact->getDefaultImType(); $contact_data['default_im'] = $default_im instanceof ImType ? $default_im->getId() : ''; } // if tpl_assign('contact', $contact); tpl_assign('company', $company); tpl_assign('contact_data', $contact_data); tpl_assign('im_types', $im_types); $avatar = array_var($_FILES, 'new_avatar'); if (is_array($avatar) && isset($avatar['size']) && $avatar['size'] != 0) { try { $old_file = $contact->getAvatarPath(); if (!isset($avatar['name']) || !isset($avatar['type']) || !isset($avatar['size']) || !isset($avatar['tmp_name']) || !is_readable($avatar['tmp_name'])) { throw new InvalidUploadError($avatar, lang('error upload file')); } // if $valid_types = array('image/jpg', 'image/jpeg', 'image/pjpeg', 'image/gif', 'image/png'); $max_width = config_option('max_avatar_width', 50); $max_height = config_option('max_avatar_height', 50); if ($avatar['size']) { if (!in_array($avatar['type'], $valid_types) || !($image = getimagesize($avatar['tmp_name']))) { throw new InvalidUploadError($avatar, lang('invalid upload type', 'JPG, GIF, PNG')); } elseif (!$contact->setAvatar($avatar['tmp_name'], $max_width, $max_height, false)) { throw new Error($avatar, lang('error edit avatar')); $contact->setAvatarFile(''); } // if if (is_file($old_file)) { @unlink($old_file); } // if } // if } catch (Exception $e) { flash_error($e->getMessage()); } // try } else { if (array_var($contact_data, 'delete_avatar') == "checked") { $old_file = $contact->getAvatarPath(); if (is_file($old_file)) { @unlink($old_file); } // if $contact->setAvatarFile(''); } } // if if (is_array(array_var($_POST, 'contact'))) { try { DB::beginWork(); $contact->setFromAttributes($contact_data); $contact->save(); if (plugin_active('tags')) { $contact->setTagsFromCSV(array_var($contact_data, 'tags')); } $contact->clearImValues(); foreach ($im_types as $im_type) { $value = trim(array_var($contact_data, 'im_' . $im_type->getId())); if ($value != '') { $contact_im_value = new ContactImValue(); $contact_im_value->setContactId($contact->getId()); $contact_im_value->setImTypeId($im_type->getId()); $contact_im_value->setValue($value); $contact_im_value->setIsDefault(array_var($contact_data, 'default_im') == $im_type->getId()); $contact_im_value->save(); } // if } // foreach ApplicationLogs::createLog($contact, null, ApplicationLogs::ACTION_ADD); DB::commit(); flash_success(lang('success edit contact', $contact->getDisplayName())); if (!logged_user()->isMemberOfOwnerCompany()) { $this->redirectToUrl(logged_user()->getAccountUrl()); } else { $this->redirectToUrl($contact->getCompany()->getViewUrl()); // Translate to profile page } // if } catch (Exception $e) { DB::rollback(); tpl_assign('error', $e); } // try } // if }
?> </span></li> <?php } // foreach ?> </ul> </div> </div> <?php } // if ?> <?php if (plugin_active('files')) { if (isset($important_files) && is_array($important_files) && count($important_files)) { ?> <div class="sidebarBlock"> <h2><?php echo lang('important files'); ?> </h2> <div class="blockContent"> <ul> <?php foreach ($important_files as $important_file) { ?> <li class="<?php echo odd_even_class($files_ln); ?>
/** * Edit specific message * * @access public * @param void * @return null */ function edit() { $this->addHelper('textile'); $this->setTemplate('add_message'); $message = ProjectMessages::findById(get_id()); if (!$message instanceof ProjectMessage) { flash_error(lang('message dnx')); $this->redirectTo('message'); } // if if (!$message->canEdit(logged_user())) { flash_error(lang('no access permissions')); $this->redirectTo('message'); } // if $message_data = array_var($_POST, 'message'); $this->setSidebar(get_template_path('textile_help_sidebar')); if (!is_array($message_data)) { $tag_names = plugin_active('tags') ? $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 $this->setSidebar(get_template_path('textile_help_sidebar')); tpl_assign('message', $message); tpl_assign('message_data', $message_data); if (is_array(array_var($_POST, 'message'))) { try { $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(); if (plugin_active('tags')) { $message->setTagsFromCSV(array_var($message_data, 'tags')); } ApplicationLogs::createLog($message, $message->getProject(), ApplicationLogs::ACTION_EDIT); DB::commit(); flash_success(lang('success edit message', $message->getTitle())); $this->redirectToUrl($message->getViewUrl()); } catch (Exception $e) { DB::rollback(); tpl_assign('error', $e); } // try } // if }
/** * Load language settings * * @param void * @throws DirDnxError If language dir does not exists * @throws FileDnxError If language settings file for this local settings * does not exists in lanuage dir */ private function loadLanguageSettings() { trace(__FILE__, 'loadLanguageSettings()'); // Check dir... $language_dir = $this->getLanguageDirPath(); if (!is_dir($language_dir)) { throw new DirDnxError($language_dir); } // if $locale = $this->getLocale(); $locale_dir = $language_dir . '/' . $locale; if (!is_dir($locale_dir)) { throw new DirDnxError($locale_dir); } // if // Get settings file path and include it $settings_file = $locale_dir . '/' . $locale . '.php'; if (!is_file($settings_file)) { trace(__FILE__, 'loadLanguageSettings()'); throw new FileDnxError($settings_file, "Failed to find language settings file" . $settings_file); } trace(__FILE__, 'loadLanguageSettings():include_once ' . $settings_file); include_once $settings_file; // Clear langs $this->langs->clear(); // Load core language files $this->loadLanguageFiles($locale_dir); // load every plugin language files $dirs = get_dirs(PLUGINS_DIR, false); foreach ($dirs as $plugin_dir) { if (plugin_active($plugin_dir)) { // plugin_dir is same as plugin name $locale_dir = PLUGINS_DIR . '/' . $plugin_dir . '/language/' . $locale; if (is_dir($locale_dir)) { $this->loadLanguageFiles($locale_dir); } else { //$locale_dir = PLUGINS_DIR.'/'.$plugin_dir.'/language/en_us'; if (is_dir($locale_dir)) { $this->loadLanguageFiles($locale_dir); } // if } // if } // if } // foreach // Done! return true; }
/** * Clear object tags * * @access public * @param void * @return boolean */ function clearTags() { if (!plugin_active('tags')) { return null; } if (!$this->isTaggable()) { throw new Error('Object not taggable'); } return Tags::clearObjectTags($this, get_class($this->manager())); }
echo lang('file revision info long', $last_revision->getRevisionNumber(), $last_revision->getCreatedBy()->getCardUrl(), clean($last_revision->getCreatedBy()->getDisplayName()), format_descriptive_date($last_revision->getCreatedOn())); } else { ?> <?php echo lang('file revision info short', $last_revision->getRevisionNumber(), format_descriptive_date($last_revision->getCreatedOn())); } // if ?> </div> <?php } // if ?> --> <?php if (plugin_active('tags')) { if (project_object_tags($file, $file->getProject()) != '--') { ?> <div id="fileTags"><span class="propertyName"><?php echo lang('tags'); ?> :</span> <?php echo project_object_tags($file, $file->getProject()); ?> </div> <?php } // if } // if $options = array();
change_plugin($plugin); redirect('plugins.php?success=' . i18n_r('PLUGIN_UPDATED')); } else { redirect('plugins.php?error=' . i18n_r('ERROR_OCCURED')); } } // Variable settings $counter = 0; $table = ''; $needsupdate = false; $plugin_info_sorted = subval_sort($plugin_info, 'name'); foreach ($plugin_info_sorted as $pluginid => $plugininfo) { $setNonce = '&nonce=' . get_nonce("set_" . $pluginid, "plugins.php"); // @todo disabled plugins have a version of (str) 'disabled', should be 0 or null $pluginver = $plugininfo['version'] == 'disabled' ? 0 : $plugininfo['version']; if (plugin_active($pluginid)) { $cls_Enabled = 'hidden'; $cls_Disabled = ''; $trclass = 'enabled'; } else { $cls_Enabled = ''; $cls_Disabled = 'hidden'; $trclass = 'disabled'; } // get extend api for this plugin filename $api_data = json_decode(get_api_details('plugin', $pluginid)); $updatelink = ''; // api success if (is_object($api_data) && $api_data->status == 'successful') { $apiver = $api_data->version; $apipath = $api_data->path;
/** * Returns a total count of all tickets. * * @access public * @param void * @return string */ function getTotalTicketCount() { if (!plugin_active('tickets')) { return 0; } return ProjectTickets::count('`milestone_id` = ' . DB::escape($this->getId())); }
/** * Edit task list * * @access public * @param void * @return null */ function edit_list() { $this->setTemplate('add_list'); $task_list = ProjectTaskLists::findById(get_id()); if (!$task_list instanceof ProjectTaskList) { flash_error(lang('task list dnx')); $this->redirectTo('task'); } // if if (!$task_list->canEdit(logged_user())) { flash_error(lang('no access permissions')); $this->redirectTo('task'); } // if $task_list_data = array_var($_POST, 'task_list'); if (!is_array($task_list_data)) { $tag_names = plugin_active('tags') ? $task_list->getTagNames() : ''; $task_list_data = array('name' => $task_list->getName(), 'priority' => $task_list->getPriority(), 'score' => $task_list->getScore(), 'description' => $task_list->getDescription(), 'start_date' => $task_list->getStartDate(), 'due_date' => $task_list->getDueDate(), 'milestone_id' => $task_list->getMilestoneId(), 'tags' => is_array($tag_names) && count($tag_names) ? implode(', ', $tag_names) : '', 'is_private' => $task_list->isPrivate()); // array } // if tpl_assign('task_list', $task_list); tpl_assign('task_list_data', $task_list_data); if (is_array(array_var($_POST, 'task_list'))) { $old_is_private = $task_list->isPrivate(); if (isset($_POST['task_list_start_date'])) { $task_list_data['start_date'] = DateTimeValueLib::makeFromString($_POST['task_list_start_date']); } if (isset($_POST['task_list_due_date'])) { $task_list_data['due_date'] = DateTimeValueLib::makeFromString($_POST['task_list_due_date']); } //$task_list_data['due_date'] = DateTimeValueLib::make(0, 0, 0, array_var($_POST, 'task_list_due_date_month', 1), array_var($_POST, 'task_list_due_date_day', 1), array_var($_POST, 'task_list_due_date_year', 1970)); $task_list->setFromAttributes($task_list_data); if (!logged_user()->isMemberOfOwnerCompany()) { $task_list->setIsPrivate($old_is_private); } try { DB::beginWork(); $task_list->save(); if (plugin_active('tags')) { $task_list->setTagsFromCSV(array_var($task_list_data, 'tags')); } ApplicationLogs::createLog($task_list, active_project(), ApplicationLogs::ACTION_EDIT); DB::commit(); flash_success(lang('success edit task list', $task_list->getName())); $this->redirectToUrl($task_list->getViewUrl()); } catch (Exception $e) { DB::rollback(); tpl_assign('error', $e); } // try } // if }