Example #1
0
 public static function sendNotification($c, $projects, $send_to, $sf_user)
 {
     foreach ($send_to as $type => $users) {
         switch ($type) {
             case 'status':
                 $subject = t::__('Project Status Updated');
                 break;
             default:
                 $subject = t::__('New Project');
                 break;
         }
         $to = array();
         foreach ($users as $v) {
             if ($u = Doctrine_Core::getTable('Users')->find($v)) {
                 $to[$u->getEmail()] = $u->getName();
             }
         }
         $user = $sf_user->getAttribute('user');
         $from[$user->getEmail()] = $user->getName();
         $to[$projects->getUsers()->getEmail()] = $projects->getUsers()->getName();
         $to[$user->getEmail()] = $user->getName();
         if (sfConfig::get('app_send_email_to_owner') == 'off') {
             unset($to[$user->getEmail()]);
         }
         $subject .= ': ' . $projects->getName() . ($projects->getProjectsStatusId() > 0 ? ' [' . $projects->getProjectsStatus()->getName() . ']' : '');
         $body = $c->getComponent('projects', 'emailBody', array('projects' => $projects));
         Users::sendEmail($from, $to, $subject, $body, $sf_user);
     }
 }
Example #2
0
 public static function getPublicStatusList()
 {
     $list = array();
     $list[1] = t::__('Use for public tickets');
     $list[2] = t::__('Only for public tickets');
     $list[3] = t::__('Don\'t use for public tickets');
     return $list;
 }
Example #3
0
 public function executeDelete(sfWebRequest $request)
 {
     $this->forward404Unless($this->users_groups = Doctrine_Core::getTable('UsersGroups')->find(array($request->getParameter('id'))), sprintf('Object users_groups does not exist (%s).', $request->getParameter('id')));
     $this->count_users = UsersGroups::countUsersByGroupId($request->getParameter('id'));
     if ($request->isMethod(sfRequest::PUT) and $this->count_users == 0) {
         $this->users_groups->delete();
         $this->getUser()->setFlash('userNotices', t::__('User Group Deleted'));
         $this->redirect('usersGroups/index');
     }
 }
Example #4
0
 public function configure()
 {
     $project_access_choices = array('1' => t::__('Full Access'), '2' => t::__('View Only'), '3' => t::__('View Own Only'), '4' => t::__('Manage Own Only'));
     $default_choices = array('' => t::__('None'), '1' => t::__('Full Access'), '2' => t::__('View Only'), '3' => t::__('View Own Only'), '4' => t::__('Manage Own Only'));
     $this->widgetSchema['allow_manage_projects'] = new sfWidgetFormChoice(array('choices' => $project_access_choices));
     $this->widgetSchema['allow_manage_tasks'] = new sfWidgetFormChoice(array('choices' => $default_choices));
     $this->widgetSchema['allow_manage_tickets'] = new sfWidgetFormChoice(array('choices' => $default_choices));
     $this->widgetSchema['allow_manage_discussions'] = new sfWidgetFormChoice(array('choices' => $default_choices));
     $this->widgetSchema['allow_manage_users'] = new sfWidgetFormInputCheckbox(array(), array('value' => 1));
     $this->widgetSchema['allow_manage_configuration'] = new sfWidgetFormInputCheckbox(array(), array('value' => 1));
     $this->widgetSchema['name']->setAttribute('class', 'required');
     $this->widgetSchema->setLabels(array('allow_manage_projects' => 'Projects', 'allow_manage_tasks' => 'Tasks', 'allow_manage_tickets' => 'Tickets', 'allow_manage_discussions' => 'Discussions', 'allow_manage_configuration' => 'Configuration', 'allow_manage_users' => 'Users'));
 }
Example #5
0
 public static function getTypesChoices()
 {
     $l = array();
     $l['text'] = t::__('Input Field');
     $l['number'] = t::__('Input Numeric Field');
     $l['url'] = t::__('Input URL Field');
     $l['file'] = t::__('File');
     $l['textarea'] = t::__('Textarea');
     $l['textarea_wysiwyg'] = t::__('Textarea with WYSIWYG editor');
     $l['date_dropdown'] = t::__('Date');
     $l['date'] = t::__('Date with calendar picker');
     $l['date_time'] = t::__('Date with calendar and time picker');
     $l['date_range'] = t::__('Date range with calendar picker');
     return $l;
 }
Example #6
0
 protected function getMoreActions(sfWebRequest $request)
 {
     $more_actions = array();
     $s = array();
     if (Users::hasAccess('edit', 'tasks', $this->getUser(), $request->getParameter('projects_id'))) {
         $s[] = array('title' => t::__('Move To'), 'url' => 'tasks/moveTo?tasks_id=' . $request->getParameter('tasks_id') . '&projects_id=' . $request->getParameter('projects_id') . '&redirect_to=tasksComments', 'modalbox' => true);
     }
     if (Users::hasAccess('delete', 'tasks', $this->getUser(), $request->getParameter('projects_id'))) {
         $s[] = array('title' => t::__('Delete'), 'url' => 'tasks/delete?id=' . $request->getParameter('tasks_id') . '&projects_id=' . $request->getParameter('projects_id'), 'confirm' => true);
     }
     if (count($s) > 0) {
         $more_actions[] = array('title' => t::__('More Actions'), 'submenu' => $s);
     }
     return $more_actions;
 }
Example #7
0
 public static function renderJsDictionary()
 {
     $messages = array();
     $messages[] = "Loading...";
     $messages[] = "Are you sure?";
     $messages[] = "Please Select Items";
     $messages[] = "Format";
     $messages[] = "Day";
     $messages[] = "Week";
     $messages[] = "Month";
     $messages[] = "Quarter";
     $messages[] = "Status";
     $messages[] = "Duration";
     $messages[] = "Progress";
     $messages[] = "Start Date";
     $messages[] = "Due Date";
     $messages[] = "Bold";
     $messages[] = "Italic";
     $messages[] = "Underline";
     $messages[] = "Left Align";
     $messages[] = "Numbered List";
     $messages[] = "Bulleted List";
     $messages[] = "Indent More";
     $messages[] = "Indent Less";
     $messages[] = "Strike";
     $messages[] = "Remove Formatting";
     $messages[] = "Horizontal Rule";
     $messages[] = "Image";
     $messages[] = "Text Color";
     $messages[] = "Background Color";
     $messages[] = "Source";
     $messages[] = "Code";
     $messages[] = "Quote";
     $messages[] = "Paragraph";
     $content = '
 <script type="text/javascript">
   var I18NJSText = new Array()';
     foreach ($messages as $value) {
         $content .= "\n      I18NJSText['" . addslashes($value) . "']='" . addslashes(t::__($value)) . "';\n";
     }
     $content .= "</script>\n";
     return $content;
 }
Example #8
0
 public static function sendNotification($c, $comment, $sf_user)
 {
     $user = $sf_user->getAttribute('user');
     $from = array($user->getEmail() => $user->getName());
     $to = array();
     $to[$user->getEmail()] = $user->getName();
     if ($departments = Doctrine_Core::getTable('Departments')->find($comment->getTickets()->getDepartmentsId())) {
         $to[$departments->getUsers()->getEmail()] = $departments->getUsers()->getName();
     }
     $to[$comment->getTickets()->getUsers()->getEmail()] = $comment->getTickets()->getUsers()->getName();
     $tickets_comments = Doctrine_Core::getTable('TicketsComments')->createQuery()->addWhere('tickets_id=?', $comment->getTicketsId())->orderBy('created_at desc')->execute();
     foreach ($tickets_comments as $v) {
         $to[$v->getUsers()->getEmail()] = $v->getUsers()->getName();
     }
     if (sfConfig::get('app_send_email_to_owner') == 'off') {
         unset($to[$user->getEmail()]);
     }
     $subject = t::__('New Ticket Comment') . ': ' . $comment->getTickets()->getProjects()->getName() . ' - ' . $comment->getTickets()->getName() . ($comment->getTickets()->getTicketsStatusId() > 0 ? ' [' . $comment->getTickets()->getTicketsStatus()->getName() . ']' : '');
     $body = $c->getComponent('ticketsComments', 'emailBody', array('tickets' => $comment->getTickets()));
     Users::sendEmail($from, $to, $subject, $body, $sf_user);
 }
Example #9
0
 public function executeIndex(sfWebRequest $request)
 {
     if ($request->hasParameter('delete_logo')) {
         if (is_file(sfConfig::get('sf_upload_dir') . '/' . sfConfig::get('app_app_logo'))) {
             unlink(sfConfig::get('sf_upload_dir') . '/' . sfConfig::get('app_app_logo'));
         }
     }
     if ($request->hasParameter('cfg')) {
         $cfg = $request->getParameter('cfg');
         foreach ($cfg as $key => $value) {
             $configuration = Doctrine_Core::getTable('Configuration')->createQuery('c')->addWhere('c.key = ?', $key)->fetchOne();
             if (is_array($value)) {
                 $value = implode(',', $value);
             }
             if ($key == 'app_app_logo') {
                 $file = $request->getFiles();
                 if (strlen($file['cfg_app_app_logo_file']['name']) > 0) {
                     if (getimagesize($file['cfg_app_app_logo_file']['tmp_name'])) {
                         move_uploaded_file($file['cfg_app_app_logo_file']['tmp_name'], sfConfig::get('sf_upload_dir') . '/' . $file['cfg_app_app_logo_file']['name']);
                         $value = $file['cfg_app_app_logo_file']['name'];
                     }
                 }
             }
             if ($configuration) {
                 $configuration->setValue($value);
                 $configuration->save();
             } else {
                 $sql = "INSERT INTO configuration (configuration.key, configuration.value) VALUES ('" . $key . "', '" . $value . "')";
                 $connection = Doctrine_Manager::connection();
                 $connection->execute($sql);
             }
         }
         $this->getUser()->setFlash('userNotices', t::__('Configuration has been successfully updated'));
         $this->redirect('configuration/index?type=' . $request->getParameter('type'));
     }
     app::setPageTitle('Configuration', $this->getResponse());
 }
Example #10
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $files = $request->getFiles();
     $userPhoto = $files['users']['photo']['name'];
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $user = $this->getUser()->getAttribute('user');
         $this->checkUser($form['email']->getValue(), $user->getId());
         $form->setFieldValue('users_group_id', $user->getUsersGroupId());
         $form->setFieldValue('active', $user->getActive());
         if (isset($form['new_password'])) {
             if (strlen($form['new_password']->getValue()) > 0) {
                 $form->setFieldValue('password', md5($form['new_password']->getValue()));
             }
         }
         if (strlen($userPhoto) > 0) {
             $userPhoto = rand(111111, 999999) . '-' . $userPhoto;
             $filename = sfConfig::get('sf_upload_dir') . '/users/' . $userPhoto;
             move_uploaded_file($files['users']['photo']['tmp_name'], $filename);
             $form->setFieldValue('photo', $userPhoto);
             app::image_resize($filename, $filename);
         } else {
             $form->setFieldValue('photo', $form['photo_preview']->getValue());
         }
         if ($form['remove_photo']->getValue() == 1 && strlen($form['photo_preview']->getValue()) > 0) {
             unlink(sfConfig::get('sf_upload_dir') . '/users/' . $form['photo_preview']->getValue());
             $form->setFieldValue('photo', '');
         }
         $users = $form->save();
         $this->getUser()->setAttribute('user', $users);
         $this->getUser()->setCulture($users->getCulture());
         ExtraFieldsList::setValues($request->getParameter('extra_fields'), $users->getId(), 'users', $this->getUser());
         $this->getUser()->setFlash('userNotices', t::__('Account Updated'));
         $this->redirect('myAccount/index');
     }
 }
Example #11
0
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     $this->skins_list = array();
     $skinsDir = sfConfig::get('sf_web_dir') . '/css/skins/';
     if ($handle = opendir($skinsDir)) {
         while (false !== ($file = readdir($handle))) {
             if ($file != "." && $file != ".." && is_dir($skinsDir . $file)) {
                 $this->skins_list[] = $file;
             }
         }
     }
     if ($request->hasParameter('setSkin')) {
         $setSkin = $request->getParameter('setSkin');
         if (is_file(sfConfig::get('sf_web_dir') . '/css/skins/' . $setSkin . '/styles.css')) {
             $this->getResponse()->setCookie('skin', $setSkin, time() + 31536000, '', '');
             $users = Doctrine_Core::getTable('Users')->find($this->getUser()->getAttribute('id'));
             $users->setSkin($setSkin);
             $users->save();
         } else {
             $this->getUser()->setFlash('userNotices', array('type' => 'error', 'text' => t::__('Skin style is not found. Please check next path:') . '/css/skins/' . $setSkin . '/styles.css'));
         }
         $this->redirect('dashboard/index');
     }
 }
Example #12
0
 public static function sendNotification($c, $comment, $sf_user)
 {
     $to = array();
     foreach (explode(',', $comment->getDiscussions()->getAssignedTo()) as $v) {
         if ($u = Doctrine_Core::getTable('Users')->find($v)) {
             $to[$u->getEmail()] = $u->getName();
         }
     }
     $user = $sf_user->getAttribute('user');
     $from[$user->getEmail()] = $user->getName();
     $to[$comment->getDiscussions()->getUsers()->getEmail()] = $comment->getDiscussions()->getUsers()->getName();
     $to[$user->getEmail()] = $user->getName();
     $discussions_comments = Doctrine_Core::getTable('DiscussionsComments')->createQuery()->addWhere('discussions_id=?', $comment->getDiscussionsId())->orderBy('created_at desc')->execute();
     foreach ($discussions_comments as $v) {
         $to[$v->getUsers()->getEmail()] = $v->getUsers()->getName();
     }
     if (sfConfig::get('app_send_email_to_owner') == 'off') {
         unset($to[$user->getEmail()]);
     }
     $to = array_unique($to);
     $subject = t::__('New Discussion Comment') . ': ' . $comment->getDiscussions()->getProjects()->getName() . ' - ' . $comment->getDiscussions()->getName() . ($comment->getDiscussions()->getDiscussionsStatusId() > 0 ? ' [' . $comment->getDiscussions()->getDiscussionsStatus()->getName() . ']' : '');
     $body = $c->getComponent('discussionsComments', 'emailBody', array('discussions' => $comment->getDiscussions()));
     Users::sendEmail($from, $to, $subject, $body, $sf_user);
 }
Example #13
0
 public static function getTasksColumnChoices()
 {
     return array('Id' => t::__('Id'), 'TasksGroups' => t::__('Group'), 'Versions' => t::__('Version'), 'ProjectsPhases' => t::__('Phase'), 'TasksPriority' => t::__('Priority'), 'TasksLabels' => t::__('Label'), 'Name' => t::__('Name'), 'TasksStatus' => t::__('Status'), 'TasksTypes' => t::__('Type'), 'AssignedTo' => t::__('Assigned To'), 'CreatedBy' => t::__('Created By'), 'EstimatedTime' => t::__('Est. Time'), 'WorkHours' => t::__('Work Hours'), 'StartDate' => t::__('Start Date'), 'DueDate' => t::__('Due Date'), 'Progress' => t::__('Progress'), 'CreatedAt' => t::__('Created At'));
 }
Example #14
0
 public static function renderFieldValueByType($f, $values, $extra_values = array(), $is_export = false)
 {
     $value = isset($values[$f['id']]) ? $values[$f['id']] : '';
     switch ($f['type']) {
         case 'file':
             $html = '';
             if ($a = Doctrine_Core::getTable('Attachments')->find($value)) {
                 if ($is_export) {
                     return app::public_url('attachments/download?id=' . $a->getId());
                 } else {
                     $html = Attachments::getLink($a);
                 }
             }
             return $html;
             break;
         case 'date_dropdown':
             return strlen($value) > 2 ? app::dateFormat($value, 0, $is_export ? false : true) : '';
             break;
         case 'date':
             return app::dateFormat($value, 0, $is_export ? false : true);
             break;
         case 'date_time':
             return app::dateTimeFormat($value, 0, $is_export ? false : true);
             break;
         case 'date_range':
             if (strlen($value) > 1) {
                 $value = explode('|', $value);
                 return app::dateFormat($value[0], 0, $is_export ? false : true) . ' - ' . app::dateFormat($value[1], 0, $is_export ? false : true);
             } else {
                 return '';
             }
             break;
         case 'formula':
             $formula = $f['default_values'];
             foreach ($values as $k => $v) {
                 $formula = str_replace('[' . $k . ']', (double) $v, $formula);
             }
             foreach ($extra_values as $k => $v) {
                 $formula = str_replace('[' . $k . ']', (double) $v, $formula);
             }
             if (!strstr($formula, '[')) {
                 if (strstr($formula, '{')) {
                     $eval_str = 'function getFormulaValue()' . $formula . '; $fv=getFormulaValue();';
                 } else {
                     $eval_str = '$fv=' . $formula . ';';
                 }
                 @($r = eval($eval_str));
                 if ($r !== null) {
                     $fv = $formula;
                 }
                 return $fv;
             } else {
                 return '';
             }
             break;
         case 'checkbox':
             return str_replace("\n", '<br>', $value);
             break;
         case 'url':
             if (strlen($value) > 0) {
                 if (!strstr($value, '://')) {
                     $value = 'http://' . $value;
                 }
                 if ($is_export) {
                     return $value;
                 } else {
                     return '<a href="' . $value . '" target="blank">' . t::__('view') . '</a>';
                 }
             } else {
                 return '';
             }
             break;
         case 'textarea':
             return nl2br($value);
             break;
         default:
             return $value;
             break;
     }
 }
Example #15
0
g.setFormatArr("day","week","month","quarter") // Set format options (up to 4 : "minute","hour","day","week","month","quarter")

<?php 
$taskProjectId = 0;
$parentItemId = 0;
$counter = 1;
foreach ($tasks_list as $tasks) {
    if ($tasks['projects_id'] != $taskProjectId) {
        $taskProjectId = $tasks['projects_id'];
        echo "g.AddTaskItem(new JSGantt.TaskItem(" . $counter . ", '" . addslashes($tasks['Projects']['name']) . "','','','ffe763', '" . url_for('ganttChart/index?projects_id=' . $tasks['projects_id']) . "','','',0,1,0," . $pOpen . ",'','" . url_for('projects/info?id=' . $tasks['projects_id']) . "')); \n";
        $parentItemId = $counter;
        $counter++;
    }
    $estimated_time = $tasks['estimated_time'];
    if ($estimated_time > 0) {
        $estimated_title = $estimated_time . ' ' . t::__('hours');
    } else {
        $estimated_title = '';
    }
    $start_date = app::ganttDateFormat($tasks['start_date']);
    $end_date = app::ganttDateFormat($tasks['due_date']);
    $level_padding = '';
    if (count($tasks_tree) > 0) {
        if ($tasks_tree[$tasks['id']]['level'] > 0) {
            $level_padding = str_repeat('&nbsp;-&nbsp;', $tasks_tree[$tasks['id']]['level']);
        }
    }
    echo "g.AddTaskItem(new JSGantt.TaskItem(" . $counter . ", '" . $level_padding . addslashes($tasks['name']) . "','" . $start_date . "','" . $end_date . "','ffe763', '" . url_for('tasksComments/index?tasks_id=' . $tasks['id'] . '&projects_id=' . $tasks['projects_id']) . "','','" . ($tasks['tasks_status_id'] > 0 ? addslashes($tasks['TasksStatus']['name']) : '') . "'," . (int) $tasks['progress'] . ",0," . $parentItemId . ",'','','" . url_for('tasks/info?id=' . $tasks['id'] . '&projects_id=' . $tasks['projects_id']) . "')); \n";
    $counter++;
}
?>
Example #16
0
 public function executeSendEmail(sfWebRequest $request)
 {
     $this->user = $this->getUser()->getAttribute('user');
     if ($request->isMethod(sfRequest::PUT)) {
         if ($request->hasParameter('users_groups')) {
             foreach ($request->getParameter('users_groups') as $id) {
                 $choices = Users::getEmailChoicesByGroupId($id);
                 foreach ($choices as $email => $name) {
                     $from = array($this->user->getEmail() => $this->user->getName());
                     $to = array($email => $name);
                     $subject = $request->getParameter('subject');
                     $body = $request->getParameter('message');
                     Users::sendEmail($from, $to, $subject, $body, $this->getUser(), false);
                 }
             }
             $this->getUser()->setFlash('userNotices', t::__('Message Sent'));
             $this->redirect('users/sendEmail');
         } else {
             $this->getUser()->setFlash('userNotices', array('text' => t::__('User Group is not selected'), 'type' => 'error'));
         }
     }
 }
Example #17
0
 public function executeMultipleEdit(sfWebRequest $request)
 {
     if ($request->hasParameter('projects_id')) {
         $this->forward404Unless($this->projects = Doctrine_Core::getTable('Projects')->createQuery()->addWhere('id=?', $request->getParameter('projects_id'))->fetchOne(), sprintf('Object projects does not exist (%s).', $request->getParameter('projects_id')));
         $this->checkProjectsAccess($this->projects);
         $this->checkTasksAccess('edit', false, $this->projects);
     } else {
         $this->checkTasksAccess('edit');
     }
     $this->fields = array();
     $this->numeric_fields = array();
     $choices = app::getItemsChoicesByTable('TasksPriority', true);
     if (count($choices) > 1) {
         $this->fields['tasks_priority_id'] = array('title' => t::__('Priority'), 'choices' => $choices);
     }
     $choices = app::getItemsChoicesByTable('TasksLabels', true);
     if (count($choices) > 1) {
         $this->fields['tasks_label_id'] = array('title' => t::__('Label'), 'choices' => $choices);
     }
     $choices = app::getItemsChoicesByTable('TasksStatus', true);
     if (count($choices) > 1) {
         $this->fields['tasks_status_id'] = array('title' => t::__('Status'), 'choices' => $choices);
     }
     $choices = app::getItemsChoicesByTable('TasksTypes', true);
     if (count($choices) > 1) {
         $this->fields['tasks_type_id'] = array('title' => t::__('Type'), 'choices' => $choices);
     }
     if ($request->hasParameter('projects_id')) {
         $choices = app::getItemsChoicesByTable('TasksGroups', true, $request->getParameter('projects_id'));
         if (count($choices) > 1) {
             $this->fields['tasks_groups_id'] = array('title' => t::__('Group'), 'choices' => $choices);
         }
         $choices = app::getItemsChoicesByTable('Versions', true, $request->getParameter('projects_id'));
         if (count($choices) > 1) {
             $this->fields['versions_id'] = array('title' => t::__('Version'), 'choices' => $choices);
         }
         $choices = app::getItemsChoicesByTable('ProjectsPhases', true, $request->getParameter('projects_id'));
         if (count($choices) > 1) {
             $this->fields['projects_phases_id'] = array('title' => t::__('Phase'), 'choices' => $choices);
         }
     }
     $this->fields['progress'] = array('title' => t::__('Progress'), 'choices' => Tasks::getProgressChoices());
     $extra_fields = ExtraFieldsList::getFieldsByType('tasks', $this->getUser(), false, array('all' => true));
     $this->numeric_fields['estimated_time'] = array('title' => t::__('Estimated Time'));
     foreach ($extra_fields as $v) {
         if (in_array($v['type'], array('number'))) {
             $this->numeric_fields['extra_field_' . $v['id']] = array('title' => $v['name']);
         }
     }
     if ($request->getParameter('fields')) {
         if (strlen($request->getParameter('selected_items') == 0)) {
             exit;
         }
         foreach ($request->getParameter('fields') as $key => $value) {
             if (strlen($value) == 0 and !is_array($value)) {
                 continue;
             }
             if ($key == 'tasks_status_id') {
                 foreach (explode(',', $request->getParameter('selected_items')) as $pid) {
                     if ($p = Doctrine_Core::getTable('Tasks')->find($pid)) {
                         if ($p->getTasksStatusId() != $value) {
                             $p->setTasksStatusId($value);
                             if (in_array($value, app::getStatusByGroup('closed', 'TasksStatus'))) {
                                 $p->setClosedDate(date('Y-m-d H:i:s'));
                             }
                             if (!in_array($value, app::getStatusByGroup('closed', 'TasksStatus'))) {
                                 $p->setClosedDate(null);
                             }
                             $p->save();
                             if (strlen($p->getAssignedTo()) > 0) {
                                 Tasks::sendNotification($this, $p, array('status' => explode(',', $p->getAssignedTo())), $this->getUser());
                             }
                             $c = new TasksComments();
                             $c->setTasksStatusId($value);
                             $c->setTasksId($pid);
                             $c->setCreatedAt(date('Y-m-d H:i:s'));
                             $c->setCreatedBy($this->getUser()->getAttribute('id'));
                             $c->save();
                         }
                     }
                 }
             } elseif ($key == 'estimated_time') {
                 $action_str = (double) $value;
                 if (in_array(substr($value, 0, 1), array('+', '-', '*', '/'))) {
                     $action_str = 'estimated_time ' . substr($value, 0, 1) . ' ' . (double) substr($value, 1);
                     Doctrine_Query::create()->update('Tasks')->set('estimated_time', 0)->whereIn('id', explode(',', $request->getParameter('selected_items')))->addWhere('estimated_time is null or length(estimated_time)=0')->execute();
                 }
                 Doctrine_Query::create()->update('Tasks')->set('estimated_time', $action_str)->whereIn('id', explode(',', $request->getParameter('selected_items')))->execute();
             } elseif ($key == 'assigned_to') {
                 $tasks_list = Doctrine_Core::getTable('Tasks')->createQuery()->whereIn('id', explode(',', $request->getParameter('selected_items')))->execute();
                 foreach ($tasks_list as $tasks) {
                     $tasks->setAssignedTo(implode(',', $value));
                     $tasks->save();
                     Tasks::sendNotification($this, $tasks, array('new' => $value), $this->getUser());
                     $c = new TasksComments();
                     $c->setDescription(t::__('Assigned To') . ': ' . Users::getNameById(implode(',', $value), ', '));
                     $c->setTasksId($tasks->getId());
                     $c->setCreatedAt(date('Y-m-d H:i:s'));
                     $c->setCreatedBy($this->getUser()->getAttribute('id'));
                     $c->save();
                     $tasks->save();
                 }
             } else {
                 Doctrine_Query::create()->update('Tasks')->set($key, $value)->whereIn('id', explode(',', $request->getParameter('selected_items')))->execute();
             }
         }
         $this->redirect_to($request->getParameter('redirect_to'), $request->getParameter('projects_id'), $request->getParameter('tasks_id'));
     }
 }
Example #18
0
 public static function getAccessTable($ug, $type = '', $include_reports = true)
 {
     $html = '';
     switch ($type) {
         case 'projects':
             $html = '
         <table class="listingDataTable">
           <tr>
             <td><b>' . t::__('Projects') . ':</b></td>
             <td>' . UsersGroups::getAccessNameByKey($ug->getAllowManageProjects()) . '</td>
           </tr>              
           <tr>
             <td>' . t::__('Comments') . ':</td>
             <td>' . UsersGroups::getAccessNameByValue($ug->getAllowManageProjects()) . '</td>
           </tr>
           </table>
           <table class="listingDataTable">' . ($include_reports ? '<tr>
             <td>' . t::__('Projects Reports') . ':</td>
             <td>' . UsersGroups::getAccessNameByValue($ug->getAllowManageProjects()) . '</td>
           </tr>' : '') . '
          </table>';
             break;
         case 'tasks':
             $html = '
         <table class="listingDataTable">
           <tr>
             <td ><b>' . t::__('Tasks') . ':</b></td>
             <td>' . UsersGroups::getAccessNameByKey($ug->getAllowManageTasks()) . '</td>
           </tr>
           <tr>
             <td>' . t::__('Comments') . ':</td>
             <td>' . UsersGroups::getAccessNameByValue($ug->getAllowManageTasks()) . '</td>
           </tr>
           </table>' . ($include_reports ? '<table class="listingDataTable">
           <tr>
             <td>' . t::__('Tasks Reports') . ':</td>
             <td>' . UsersGroups::getAccessNameByValue($ug->getAllowManageTasks()) . '</td>
           </tr>
           <tr>
             <td>' . t::__('Gantt Chart') . ':</td>
             <td>' . UsersGroups::getAccessNameByValue($ug->getAllowManageTasks()) . '</td>
           </tr>
           <tr>
             <td>' . t::__('Time Report') . ':</td>
             <td>' . UsersGroups::getAccessNameByValue($ug->getAllowManageTasks()) . '</td>
           </tr>
           <tr>
             <td>' . t::__('Personal Time Report') . ':</td>
             <td>' . UsersGroups::getAccessNameByValue($ug->getAllowManageTasks()) . '</td>
           </tr> 
          </table>' : '');
             break;
         case 'tickets':
             $html = '
         <table class="listingDataTable">
           <tr>
             <td style="font-size: 11px;"><b>' . t::__('Tickets') . ':</b></td>
             <td>' . UsersGroups::getAccessNameByKey($ug->getAllowManageTickets()) . '</td>
           </tr>
           <tr>
             <td>' . t::__('Comments') . ':</td>
             <td>' . UsersGroups::getAccessNameByValue($ug->getAllowManageTickets()) . '</td>
           </tr>
           </table>' . ($include_reports ? '<table class="listingDataTable">
           <tr>
             <td>' . t::__('Tickets Reports') . ':</td>
             <td>' . UsersGroups::getAccessNameByValue($ug->getAllowManageTickets()) . '</td>
           </tr> 
          </table>' : '');
             break;
         case 'discussions':
             $html = '
         <table class="listingDataTable">
           <tr>
             <td><b>' . t::__('Discussions') . ':</b></td>
             <td>' . UsersGroups::getAccessNameByKey($ug->getAllowManageDiscussions()) . '</td>
           </tr>
           <tr>
             <td>' . t::__('Comments') . ':</td>
             <td>' . UsersGroups::getAccessNameByValue($ug->getAllowManageDiscussions()) . '</td>
           </tr>
           </table>' . ($include_reports ? '<table class="listingDataTable">
           <tr>
             <td>' . t::__('Discussions Reports') . ':</td>
             <td>' . UsersGroups::getAccessNameByValue($ug->getAllowManageDiscussions()) . '</td>
           </tr> 
          </table>' : '');
             break;
         case 'extra':
             $html = '
         <table class="listingDataTable">
           <tr>
             <td><b>' . t::__('Configuration') . ':</b></td>
             <td>' . UsersGroups::getAccessNameByValue($ug->getAllowManageConfiguration()) . '</td>
           </tr>
           <tr>
             <td>' . t::__('Users') . ':</td>
             <td>' . UsersGroups::getAccessNameByValue($ug->getAllowManageUsers()) . '</td>
           </tr>
          </table>';
             break;
     }
     $html = str_replace('<td>', '<td style="white-space:normal">', $html);
     return $html;
 }
Example #19
0
 public function executeXlsTasksImportBindField(sfWebRequest $request)
 {
     $this->columns = array('TasksGroups' => t::__('Group'), 'Versions' => t::__('Version'), 'ProjectsPhases' => t::__('Phase'), 'TasksPriority' => t::__('Priority'), 'TasksLabels' => t::__('Label'), 'name' => t::__('Name'), 'TasksStatus' => t::__('Status'), 'TasksTypes' => t::__('Type'), 'assigned_to' => t::__('Assigned To'), 'estimated_time' => t::__('Est. Time'), 'start_date' => t::__('Start Date'), 'due_date' => t::__('Due Date'), 'progress' => t::__('Progress'));
     $extra_fields = ExtraFieldsList::getFieldsByType('tasks', $this->getUser(), false, array('all' => true));
     foreach ($extra_fields as $v) {
         $this->columns['extra_field_' . $v['id']] = $v['name'];
     }
     $import_fields = $this->getUser()->getAttribute('import_fields');
     foreach ($import_fields as $k => $v) {
         unset($this->columns[$v]);
     }
     if ($request->hasParameter('field_id')) {
         if ($request->getParameter('field_id') != '0') {
             $import_fields = $this->getUser()->getAttribute('import_fields');
             $import_fields[$request->getParameter('col')] = $request->getParameter('field_id');
             $this->getUser()->setAttribute('import_fields', $import_fields);
             echo $this->columns[$request->getParameter('field_id')];
         } else {
             $import_fields = $this->getUser()->getAttribute('import_fields');
             if (isset($import_fields[$request->getParameter('col')])) {
                 unset($import_fields[$request->getParameter('col')]);
             }
             $this->getUser()->setAttribute('import_fields', $import_fields);
             echo '-';
         }
         exit;
     }
 }
Example #20
0
 public function executeLdap(sfWebRequest $request)
 {
     $this->form = new LdapLoginForm();
     if ($request->isMethod('post')) {
         $this->form->bind($request->getParameter($this->form->getName()));
         if ($this->form->isValid()) {
             $ldap = new ldapLogin();
             $user_attr = $ldap->doLdapLogin($this->form['user']->getValue(), $this->form['password']->getValue());
             if ($user_attr['status'] == true) {
                 $userName = $this->form['user']->getValue();
                 $userEmail = $this->form['user']->getValue() . '@localhost.com';
                 if (strlen($user_attr['email']) > 0) {
                     $userEmail = $user_attr['email'];
                 }
                 if (strlen($user_attr['name']) > 0) {
                     $userName = $user_attr['name'];
                 }
                 $q = Doctrine_Core::getTable('Users')->createQuery()->addWhere('email=?', $userEmail);
                 if (!($user = $q->fetchOne())) {
                     $user = new Users();
                     $user->setUsersGroupId(sfConfig::get('app_ldap_default_user_group'));
                     $user->setName($userName);
                     $user->setEmail($userEmail);
                     $user->setPassword(md5($this->form['password']->getValue()));
                     $user->setActive(1);
                     $user->setCulture(sfConfig::get('sf_default_culture'));
                     $user->save();
                 } else {
                     if ($user->getActive() != 1) {
                         $this->getUser()->setFlash('userNotices', I18NText::__('Your account is not active'));
                         $this->redirect('login/ldap');
                     }
                 }
                 $this->doUserLogin($user, $request);
             } else {
                 $this->getUser()->setFlash('userNotices', t::__($user_attr['msg']));
                 $this->redirect('login/ldap');
             }
         }
     }
     app::setPageTitle('LDAP Login', $this->getResponse());
 }
Example #21
0
 public function executeMultipleEdit(sfWebRequest $request)
 {
     if ($request->getParameter('projects_id') > 0) {
         $this->forward404Unless($this->projects = Doctrine_Core::getTable('Projects')->createQuery()->addWhere('id=?', $request->getParameter('projects_id'))->fetchOne(), sprintf('Object projects does not exist (%s).', $request->getParameter('projects_id')));
         $this->checkProjectsAccess($this->projects);
         $this->checkTicketsAccess('edit', false, $this->projects);
     } else {
         $this->checkTicketsAccess('edit');
     }
     $this->fields = array();
     if ($request->getParameter('projects_id') > 0) {
         $this->fields['departments_id'] = array('title' => t::__('Department'), 'choices' => app::getItemsChoicesByTable('Departments', true));
     }
     $choices = app::getItemsChoicesByTable('TicketsStatus', true);
     if (count($choices) > 1) {
         $this->fields['tickets_status_id'] = array('title' => t::__('Status'), 'choices' => $choices);
     }
     $choices = app::getItemsChoicesByTable('TicketsTypes', true);
     if (count($choices) > 1) {
         $this->fields['tickets_types_id'] = array('title' => t::__('Type'), 'choices' => $choices);
     }
     if ($request->getParameter('fields')) {
         if (strlen($request->getParameter('selected_items') == 0)) {
             exit;
         }
         foreach ($request->getParameter('fields') as $key => $value) {
             if (strlen($value) == 0 and !is_array($value)) {
                 continue;
             }
             if ($key == 'tickets_status_id') {
                 foreach (explode(',', $request->getParameter('selected_items')) as $pid) {
                     if ($p = Doctrine_Core::getTable('Tickets')->find($pid)) {
                         if ($p->getTicketsStatusId() != $value) {
                             $p->setTicketsStatusId($value);
                             $p->save();
                             if ($p->getDepartmentsId() > 0) {
                                 Tickets::sendNotification($this, $p, array('status' => explode(',', $p->getDepartments()->getUsersId())), $this->getUser());
                             }
                             $c = new TicketsComments();
                             $c->setTicketsStatusId($value);
                             $c->setTicketsId($pid);
                             $c->setCreatedAt(date('Y-m-d H:i:s'));
                             $c->setUsersId($this->getUser()->getAttribute('id'));
                             $c->save();
                         }
                     }
                 }
             } elseif ($key == 'departments_id') {
                 foreach (explode(',', $request->getParameter('selected_items')) as $pid) {
                     if ($p = Doctrine_Core::getTable('Tickets')->find($pid)) {
                         if ($p->getDepartmentsId() != $value) {
                             $p->setDepartmentsId($value);
                             $p->save();
                             if ($p->getDepartmentsId() > 0) {
                                 Tickets::sendNotification($this, $p, array('new' => explode(',', $p->getDepartments()->getUsersId())), $this->getUser());
                             }
                         }
                     }
                 }
             } else {
                 Doctrine_Query::create()->update('Tickets')->set($key, $value)->whereIn('id', explode(',', $request->getParameter('selected_items')))->execute();
             }
         }
         $this->redirect_to($request->getParameter('redirect_to'), $request->getParameter('projects_id'), $request->getParameter('tickets_id'));
     }
 }
Example #22
0
 public function executeMultipleEdit(sfWebRequest $request)
 {
     Users::checkAccess($this, 'edit', $this->getModuleName(), $this->getUser());
     $this->fields = array();
     $choices = app::getItemsChoicesByTable('ProjectsStatus', true);
     if (count($choices) > 1) {
         $this->fields['projects_status_id'] = array('title' => t::__('Status'), 'choices' => $choices);
     }
     $choices = app::getItemsChoicesByTable('ProjectsTypes', true);
     if (count($choices) > 1) {
         $this->fields['projects_types_id'] = array('title' => t::__('Type'), 'choices' => $choices);
     }
     if ($request->getParameter('fields')) {
         if (strlen($request->getParameter('selected_items') == 0)) {
             exit;
         }
         foreach ($request->getParameter('fields') as $key => $value) {
             if (strlen($value) == 0 and !is_array($value)) {
                 continue;
             }
             if ($key == 'projects_status_id') {
                 foreach (explode(',', $request->getParameter('selected_items')) as $pid) {
                     if ($p = Doctrine_Core::getTable('Projects')->find($pid)) {
                         if ($p->getProjectsStatusId() != $value) {
                             $p->setProjectsStatusId($value);
                             $p->save();
                             if (strlen($p->getTeam()) > 0) {
                                 Projects::sendNotification($this, $p, array('status' => explode(',', $p->getTeam())), $this->getUser());
                             }
                         }
                     }
                 }
             } else {
                 Doctrine_Query::create()->update('Projects')->set($key, $value)->whereIn('id', explode(',', $request->getParameter('selected_items')))->execute();
             }
         }
         $this->redirect_to($request->getParameter('redirect_to'));
     }
 }
Example #23
0
 public function executeDoSaveFilter(sfWebRequest $request)
 {
     Tasks::saveTasksFilter($request, $this->getUser()->getAttribute('gantt_filter' . $this->get_pid($request)), $this->getUser(), 'ganttChart');
     $this->getUser()->setFlash('userNotices', t::__('Filter Saved'));
     $this->redirect('ganttChart/index' . $this->add_pid($request));
 }
Example #24
0
 public static function i18n_date()
 {
     $translate = array("am" => t::__("am"), "pm" => t::__("pm"), "AM" => t::__("AM"), "PM" => t::__("PM"), "Monday" => t::__("Monday"), "Mon" => t::__("Mon"), "Tuesday" => t::__("Tuesday"), "Tue" => t::__("Tue"), "Wednesday" => t::__("Wednesday"), "Wed" => t::__("Wed"), "Thursday" => t::__("Thursday"), "Thu" => t::__("Thu"), "Friday" => t::__("Friday"), "Fri" => t::__("Fri"), "Saturday" => t::__("Saturday"), "Sat" => t::__("Sat"), "Sunday" => t::__("Sunday"), "Sun" => t::__("Sun"), "January" => t::__("January"), "Jan" => t::__("Jan"), "February" => t::__("February"), "Feb" => t::__("Feb"), "March" => t::__("March"), "Mar" => t::__("Mar"), "April" => t::__("April"), "Apr" => t::__("Apr"), "May" => t::__("May"), "June" => t::__("June"), "Jun" => t::__("Jun"), "July" => t::__("July"), "Jul" => t::__("Jul"), "August" => t::__("August"), "Aug" => t::__("Aug"), "September" => t::__("September"), "Sep" => t::__("Sep"), "October" => t::__("October"), "Oct" => t::__("Oct"), "November" => t::__("November"), "Nov" => t::__("Nov"), "December" => t::__("December"), "Dec" => t::__("Dec"));
     if (func_num_args() > 1) {
         $timestamp = func_get_arg(1);
         return strtr(date(func_get_arg(0), $timestamp), $translate);
     } else {
         return strtr(date(func_get_arg(0)), $translate);
     }
 }