Example #1
0
 /**
  * Create new RSS file after project creation
  * @param $project
  * @return bool
  */
 public function storeProjectRssFile(Project $project)
 {
     $fileName = $this->rssDir . $this->pKey . ".rss";
     $rssLog = new Rss_log();
     $rssLog->setPid($project->getId());
     if (!$this->checkFileExists($fileName)) {
         // Create new one RSS file
         $xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"></rss>', null, false);
         $channel = $xml->addChild("channel");
         $channel->addChild("title", $project->getName());
         $channel->addChild("description", $project->getDescription());
         $channel->addChild("link", $this->partnerUrl . $project->getCruid());
         $rssLog->setTitle($project->getName());
         $rssLog->setDescription($project->getDescription());
         $rssLog->setLink($this->partnerUrl . $project->getCruid());
         $rssLog->setType("project create");
     } else {
         // Update existing RSS file
         libxml_use_internal_errors(true);
         try {
             $xml = new SimpleXMLElement($fileName, NULL, TRUE);
         } catch (Exception $er) {
             return false;
         }
         $xml = $this->openRssFile($fileName);
         if ($xml === false) {
             return false;
         }
         unset($xml->channel->title);
         unset($xml->channel->description);
         unset($xml->channel->link);
         $xml->channel->addChild("title", $project->getName());
         $xml->channel->addChild("description", $project->getDescription());
         $xml->channel->addChild("link", $this->partnerUrl . $project->getCruid());
         $rssLog->setTitle($project->getName());
         $rssLog->setDescription($project->getDescription());
         $rssLog->setLink($this->partnerUrl . $project->getCruid());
         $rssLog->setType("project update");
     }
     try {
         $xml->asXML($fileName);
     } catch (Exception $er) {
         return false;
     }
     $rssLog->setR_date(\Carbon\Carbon::Now()->toDateTimeString());
     $this->storeRssLog($rssLog);
     return true;
 }
 private function workspace_toxml(Project $ws, $activeProjects)
 {
     $parentIds = '';
     $i = 1;
     $pid = $ws->getPID($i);
     while ($pid != $ws->getId() && $pid != 0 && $i <= 10) {
         $coma = $parentIds == '' ? '' : ',';
         if (in_array($pid, $activeProjects)) {
             $parentIds .= $coma . $pid;
         }
         $i++;
         $pid = $ws->getPID($i);
     }
     $this->instance->startElement('workspace');
     $this->instance->startElement('id');
     $this->instance->text($ws->getId());
     $this->instance->endElement();
     $this->instance->startElement('name');
     $this->instance->text($ws->getName());
     $this->instance->endElement();
     $this->instance->startElement('description');
     $this->instance->text($ws->getDescription());
     $this->instance->endElement();
     $this->instance->startElement('parentids');
     $this->instance->text($parentIds);
     $this->instance->endElement();
     $this->instance->endElement();
 }
 public function setProject(Project $project)
 {
     $this->project = $project;
     $url = parent::getUrl();
     $url->setQueryVar('page', 'project');
     $url->setQueryVar('id', $project->getID());
     $this->setContent($project->getName());
 }
 public function add(Project $project)
 {
     $db = $this->connection();
     $sql = "INSERT INTO {$this->dbTable} (" . self::$key . ", " . self::$name . ", " . self::$owner . ") VALUES (?, ?, ?)";
     $params = array($project->getUnique(), $project->getName(), $project->getOwner()->getUnique());
     $query = $db->prepare($sql);
     $query->execute($params);
 }
Example #5
0
 public static function show($id)
 {
     // Lists all tasks in project $id
     self::check_logged_in();
     $tasks = Task::listProject($id);
     $project_name = Project::getName($id);
     //Kint::dump($tasks);
     //View::make('project/show.html', array('tasks' => $tasks));
     View::make('project/show.html', array('tasks' => $tasks, 'project_name' => $project_name));
 }
Example #6
0
 function new_form($params)
 {
     if (!$params['project_id']) {
         bail('Required parameter "project_id" is missing.');
     }
     $project = new Project($params['project_id']);
     $this->options = array('project_id' => $project->id, 'title' => $project->getName());
     $this->data = new Hour();
     $this->data->set(array('staff_id' => Session::getUserId(), 'date' => date('Y-m-d')));
 }
Example #7
0
 public function updateProject(Project $project)
 {
     $stmt = $this->db->prepare('INSERT OR REPLACE INTO project (slug, name, repository, branch, command, url_pattern) VALUES (:slug, :name, :repository, :branch, :command, :url_pattern)');
     $stmt->bindValue(':slug', $project->getSlug(), SQLITE3_TEXT);
     $stmt->bindValue(':name', $project->getName(), SQLITE3_TEXT);
     $stmt->bindValue(':repository', $project->getRepository(), SQLITE3_TEXT);
     $stmt->bindValue(':branch', $project->getBranch(), SQLITE3_TEXT);
     $stmt->bindValue(':command', $project->getCommand(), SQLITE3_TEXT);
     $stmt->bindValue(':url_pattern', $project->getUrlPattern(), SQLITE3_TEXT);
     if (false === $stmt->execute()) {
         // @codeCoverageIgnoreStart
         throw new \RuntimeException(sprintf('Unable to save project "%s".', $project->getName()));
         // @codeCoverageIgnoreEnd
     }
     // related commits
     $stmt = $this->db->prepare('SELECT sha, author, date, build_date, message, status, output FROM `commit` WHERE slug = :slug ORDER BY build_date DESC LIMIT 100');
     $stmt->bindValue(':slug', $project->getSlug(), SQLITE3_TEXT);
     if (false === ($results = $stmt->execute())) {
         // @codeCoverageIgnoreStart
         throw new \RuntimeException(sprintf('Unable to get latest commit for project "%s".', $project->getName()));
         // @codeCoverageIgnoreEnd
     }
     $commits = array();
     while ($result = $results->fetchArray(\SQLITE3_ASSOC)) {
         $commits[] = $this->createCommit($project, $result);
     }
     $project->setCommits($commits);
     // project building?
     $stmt = $this->db->prepare('SELECT COUNT(*) AS count FROM `commit` WHERE slug = :slug AND status = "building"');
     $stmt->bindValue(':slug', $project->getSlug(), SQLITE3_TEXT);
     $building = false;
     if (false !== ($result = $stmt->execute())) {
         if (false !== ($result = $result->fetchArray(\SQLITE3_ASSOC))) {
             if ($result['count'] > 0) {
                 $building = true;
             }
         }
     }
     $project->setBuilding($building);
 }
 function test_getName()
 {
     //Arrange
     $name = "Build a shed";
     $motivation = "have storage";
     $due_date = "2015-09-09";
     $priority = 1;
     $test_project = new Project($name, $motivation, $due_date, $priority);
     //Act
     $result = $test_project->getName();
     //Assert
     $this->assertEquals($name, $result);
 }
 /**
  * Constructor
  *
  * @param Request $request
  * @return MobileAccessController extends ApplicationController 
  */
 function __construct($request)
 {
     parent::__construct($request);
     $this->disableCategories();
     $project_id = $this->request->get('project_id');
     if ($project_id) {
         $this->active_project = Projects::findById($project_id);
     }
     // if
     if (!instance_of($this->active_project, 'Project')) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     if (!$this->logged_user->isProjectMember($this->active_project)) {
         $this->httpError(HTTP_ERR_FORBIDDEN);
     }
     // if
     if ($this->active_project->getType() == PROJECT_TYPE_SYSTEM) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     $this->project_sections = array();
     $this->project_sections[] = array("name" => "overview", "full_name" => lang("Overview"), "url" => assemble_url('mobile_access_view_project', array('project_id' => $this->active_project->getId())));
     if (module_loaded('discussions') && $this->logged_user->getProjectPermission('discussion', $this->active_project)) {
         $this->project_sections[] = array("name" => "discussions", "full_name" => lang("Discussions"), "url" => assemble_url('mobile_access_view_discussions', array('project_id' => $this->active_project->getId())));
     }
     if (module_loaded('milestones') && $this->logged_user->getProjectPermission('milestone', $this->active_project)) {
         $this->project_sections[] = array("name" => "milestones", "full_name" => lang("Milestones"), "url" => assemble_url('mobile_access_view_milestones', array('project_id' => $this->active_project->getId())));
     }
     if (module_loaded('files') && $this->logged_user->getProjectPermission('file', $this->active_project)) {
         $this->project_sections[] = array("name" => "files", "full_name" => lang("Files"), "url" => assemble_url('mobile_access_view_files', array('project_id' => $this->active_project->getId())));
     }
     if (module_loaded('checklists') && $this->logged_user->getProjectPermission('checklist', $this->active_project)) {
         $this->project_sections[] = array("name" => "checklists", "full_name" => lang("Checklists"), "url" => assemble_url('mobile_access_view_checklists', array('project_id' => $this->active_project->getId())));
     }
     if (module_loaded('pages') && $this->logged_user->getProjectPermission('page', $this->active_project)) {
         $this->project_sections[] = array("name" => "pages", "full_name" => lang("Pages"), "url" => assemble_url('mobile_access_view_pages', array('project_id' => $this->active_project->getId())));
     }
     if (module_loaded('tickets') && $this->logged_user->getProjectPermission('ticket', $this->active_project)) {
         $this->project_sections[] = array("name" => "tickets", "full_name" => lang("Tickets"), "url" => assemble_url('mobile_access_view_tickets', array('project_id' => $this->active_project->getId())));
     }
     if (module_loaded('timetracking') && $this->logged_user->getProjectPermission('timerecord', $this->active_project)) {
         $this->project_sections[] = array("name" => "timetracking", "full_name" => lang("Time"), "url" => assemble_url('mobile_access_view_timerecords', array('project_id' => $this->active_project->getId())));
     }
     if (module_loaded('source') && $this->logged_user->getProjectPermission('repository', $this->active_project)) {
         $this->project_sections[] = array("name" => "source", "full_name" => lang("Repositories"), "url" => assemble_url('mobile_access_view_repositories', array('project_id' => $this->active_project->getId())));
     }
     //if($this->active_project->isLoaded() && $this->enable_categories) {
     $this->addBreadcrumb(lang('Project'), assemble_url('mobile_access_view_project', array("project_id" => $this->active_project->getId())));
     $this->smarty->assign(array("page_title" => $this->active_project->getName(), "active_project" => $this->active_project, "project_sections" => $this->project_sections, "page_breadcrumbs" => $this->breadcrumbs, "active_project_section" => 'overview', "active_category" => $this->active_category));
 }
 /**
  * Serve iCal data
  *
  * @param void
  * @return null
  */
 function ical()
 {
     if ($this->active_project->isNew()) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     $filter = ProjectUsers::getVisibleTypesFilterByProject($this->logged_user, $this->active_project, get_completable_project_object_types());
     if ($filter) {
         $objects = ProjectObjects::find(array('conditions' => array($filter . ' AND completed_on IS NULL AND state >= ? AND visibility >= ?', STATE_VISIBLE, $this->logged_user->getVisibility()), 'order' => 'priority DESC'));
         render_icalendar($this->active_project->getName() . ' ' . lang('calendar'), $objects);
         die;
     } else {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
 }
Example #11
0
 private function buildFiles(\Project $project)
 {
     $translations = $project->getTranslations();
     $builder = new KdybyTranslationBuilder();
     $files = [];
     foreach ($translations as $translation) {
         $mask = '%s.' . $translation->getLocale() . '.neon';
         $dictionaryData = $this->translationFacade->getDictionaryData($translation);
         $outputFiles = $builder->build($mask, $dictionaryData);
         $files = array_merge($files, $outputFiles);
     }
     $zip = new ZipStream(sprintf('%s.zip', $project->getName()));
     foreach ($files as $fileName => $messages) {
         $data = Neon::encode($messages, Neon::BLOCK);
         $zip->addFile($fileName, $data);
     }
     $zip->finish();
 }
Example #12
0
    if (@$HTTP_POST_VARS["cat"] == "save") {
        $tpl->assign("result", Display_Column::save());
    }
    $page = 'list_issues';
    $available = Display_Column::getAllColumns($page);
    $selected = Display_Column::getSelectedColumns($prj_id, $page);
    // re-order available array to match rank
    $available_ordered = array();
    foreach ($selected as $field_name => $field_info) {
        $available_ordered[$field_name] = $available[$field_name];
        unset($available[$field_name]);
    }
    if (count($available) > 0) {
        $available_ordered += $available;
    }
    $excluded_roles = array();
    if (!Customer::hasCustomerIntegration($prj_id)) {
        $excluded_roles[] = "customer";
    }
    $user_roles = User::getRoles($excluded_roles);
    $user_roles[9] = "Never Display";
    // generate ranks
    $ranks = array();
    for ($i = 1; $i <= count($available_ordered); $i++) {
        $ranks[$i] = $i;
    }
    $tpl->assign(array("available" => $available_ordered, "selected" => $selected, "user_roles" => $user_roles, "page" => $page, "ranks" => $ranks, "prj_id" => $prj_id, "project_name" => Project::getName($prj_id)));
} else {
    $tpl->assign("show_not_allowed_msg", true);
}
$tpl->displayTemplate();
Example #13
0
    }
} elseif (@$_GET['post_form'] == 'yes') {
    // only list those projects that are allowing anonymous reporting of new issues
    $projects = Project::getAnonymousList();
    if (empty($projects)) {
        $tpl->assign('no_projects', '1');
    } else {
        if (!in_array($_GET['project'], array_keys($projects))) {
            $tpl->assign('no_projects', '1');
        } else {
            // get list of custom fields for the selected project
            $options = Project::getAnonymousPostOptions($_GET['project']);
            if (@$options['show_custom_fields'] == 'yes') {
                $tpl->assign('custom_fields', Custom_Field::getListByProject($_GET['project'], 'anonymous_form'));
            }
            $tpl->assign('project_name', Project::getName($_GET['project']));
        }
    }
} else {
    // only list those projects that are allowing anonymous reporting of new issues
    $projects = Project::getAnonymousList();
    if (empty($projects)) {
        $tpl->assign('no_projects', '1');
    } else {
        if (count($projects) == 1) {
            $project_ids = array_keys($projects);
            Auth::redirect('post.php?post_form=yes&project=' . $project_ids[0]);
        } else {
            $tpl->assign('projects', $projects);
        }
    }
include_once APP_INC_PATH . "class.misc.php";
include_once APP_INC_PATH . "class.project.php";
include_once APP_INC_PATH . "class.setup.php";
include_once APP_INC_PATH . "db_access.php";
$tpl = new Template_API();
$tpl->setTemplate("manage/index.tpl.html");
Auth::checkAuthentication(APP_COOKIE);
$tpl->assign("type", "issue_auto_creation");
@($ema_id = $HTTP_POST_VARS["ema_id"] ? $HTTP_POST_VARS["ema_id"] : $HTTP_GET_VARS["ema_id"]);
$role_id = Auth::getCurrentRole();
if ($role_id == User::getRoleID('administrator') || $role_id == User::getRoleID('manager')) {
    if ($role_id == User::getRoleID('administrator')) {
        $tpl->assign("show_setup_links", true);
    }
    $prj_id = Email_Account::getProjectID($ema_id);
    if (@$HTTP_POST_VARS["cat"] == "update") {
        @Email_Account::updateIssueAutoCreation($ema_id, $HTTP_POST_VARS['issue_auto_creation'], $HTTP_POST_VARS['options']);
    }
    // load the form fields
    $tpl->assign("info", Email_Account::getDetails($ema_id));
    $tpl->assign("cats", Category::getAssocList($prj_id));
    $tpl->assign("priorities", Priority::getList($prj_id));
    $tpl->assign("users", Project::getUserAssocList($prj_id, 'active'));
    $tpl->assign("options", Email_Account::getIssueAutoCreationOptions($ema_id));
    $tpl->assign("ema_id", $ema_id);
    $tpl->assign("prj_title", Project::getName($prj_id));
    $tpl->assign("uses_customer_integration", Customer::hasCustomerIntegration($prj_id));
} else {
    $tpl->assign("show_not_allowed_msg", true);
}
$tpl->displayTemplate();
 function get_workspace_info(Project $workspace, $defaultParent = 0, $all_ws = null)
 {
     $parent = $defaultParent;
     if (!$all_ws) {
         $all_ws = logged_user()->getWorkspaces(true);
     }
     if (!is_array($all_ws)) {
         $all_ws = array();
     }
     $wsset = array();
     foreach ($all_ws as $w) {
         $wsset[$w->getId()] = true;
     }
     $tempParent = $workspace->getParentId();
     $x = $workspace;
     while ($x instanceof Project && !isset($wsset[$tempParent])) {
         $tempParent = $x->getParentId();
         $x = $x->getParentWorkspace();
     }
     if (!$x instanceof Project) {
         $tempParent = 0;
     }
     $workspace_info = array("id" => $workspace->getId(), "name" => $workspace->getName(), "color" => $workspace->getColor(), "parent" => $tempParent, "realParent" => $workspace->getParentId(), "depth" => $workspace->getDepth());
     if (logged_user()->getPersonalProjectId() == $workspace->getId()) {
         $workspace_info["isPersonal"] = true;
     }
     return $workspace_info;
 }
 /**
  * Method used to get the list of available support email 
  * accounts in the system.
  *
  * @access  public
  * @return  array The list of accounts
  */
 function getList()
 {
     $stmt = "SELECT\n                    *\n                 FROM\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "email_account\n                 ORDER BY\n                    ema_hostname";
     $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
     if (PEAR::isError($res)) {
         Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
         return "";
     } else {
         for ($i = 0; $i < count($res); $i++) {
             $res[$i]["prj_title"] = Project::getName($res[$i]["ema_prj_id"]);
         }
         return $res;
     }
 }
Example #17
0
    $tpl->assign("delete_phone_result", $res);
} elseif (@$HTTP_GET_VARS["cat"] == "new_status") {
    // XXX: need to call the workflow api in the following function?
    $res = Issue::setStatus($HTTP_GET_VARS["iss_id"], $HTTP_GET_VARS["new_sta_id"], true);
    if ($res == 1) {
        History::add($HTTP_GET_VARS["iss_id"], $usr_id, History::getTypeID('status_changed'), "Issue manually set to status '" . Status::getStatusTitle($HTTP_GET_VARS["new_sta_id"]) . "' by " . User::getFullName($usr_id));
    }
    $tpl->assign("new_status_result", $res);
} elseif (@$HTTP_GET_VARS["cat"] == "new_category") {
    $res = Issue::setCategory($HTTP_GET_VARS["iss_id"], $HTTP_GET_VARS["iss_prc_id"], true);
    if ($res == 1) {
        History::add($HTTP_GET_VARS["iss_id"], $usr_id, History::getTypeID('status_changed'), "Issue manually set to category '" . Category::getTitle($HTTP_GET_VARS["iss_prc_id"]) . "' by " . User::getFullName($usr_id));
    }
    $tpl->assign("new_status_result", $res);
} elseif (@$HTTP_GET_VARS["cat"] == "new_project") {
    $res = Issue::setProject($HTTP_GET_VARS["iss_id"], $HTTP_GET_VARS["iss_prj_id"], true);
    if ($res == 1) {
        History::add($HTTP_GET_VARS["iss_id"], $usr_id, History::getTypeID('status_changed'), "Issue manually set to project '" . Project::getName($HTTP_GET_VARS["iss_prj_id"]) . "' by " . User::getFullName($usr_id));
    }
    $tpl->assign("new_status_result", $res);
} elseif (@$HTTP_GET_VARS['cat'] == 'authorize_reply') {
    $res = Authorized_Replier::addUser($HTTP_GET_VARS["iss_id"], $usr_id);
    $tpl->assign('authorize_reply_result', $res);
} elseif (@$HTTP_GET_VARS['cat'] == 'remove_quarantine') {
    if (Auth::getCurrentRole() > User::getRoleID('Developer')) {
        $res = Issue::setQuarantine($HTTP_GET_VARS['iss_id'], 0);
        $tpl->assign('remove_quarantine_result', $res);
    }
}
$tpl->assign("current_user_prefs", Prefs::get($usr_id));
$tpl->displayTemplate();
Example #18
0
 function getHomeTabContent($user_id = '', $tickets_due_flag = '')
 {
     require_once SMARTY_PATH . '/plugins/modifier.html_excerpt.php';
     if (empty($user_id)) {
         $user_id = $this->getId();
     }
     $link = mysql_connect(DB_HOST, DB_USER, DB_PASS);
     mysql_select_db(DB_NAME, $link);
     $query = "select setting_value from healingcrystals_user_settings where user_id='" . $user_id . "' and setting_type='HOMETAB_LAYOUT'";
     $result = mysql_query($query);
     if (mysql_num_rows($result)) {
         $info = mysql_fetch_assoc($result);
         $layout_type = $info['setting_value'];
     } else {
         $layout_type = 'summary';
     }
     //possible values for tickets_due_flag: 'due' or 'all'
     if (empty($tickets_due_flag)) {
         $tickets_due_flag = 'due';
     }
     $query = '';
     if ($tickets_due_flag == 'due') {
         $query = "SELECT a.id, a.type, b.user_id, c.reminder_date, IF(c.reminder_date is null, a.due_on, IF(a.due_on<=c.reminder_date, a.due_on, c.reminder_date)) as old_date\n                      FROM healingcrystals_project_objects a\n                      inner join healingcrystals_assignments b on a.id=b.object_id\n                      left outer join healingcrystals_project_object_misc c on (a.id=c.object_id)\n                      where a.state='" . STATE_VISIBLE . "' and b.user_id='" . $user_id . "' and b.is_owner='1' and\n                      (a.type='Task' or a.type='Ticket') and (a.completed_on is null or a.completed_on='') and\n                      ((c.reminder_date is not null and c.reminder_date<>'0000-00-00' and c.reminder_date<=now()) or (a.due_on is not null and a.due_on<=now()) )\n                       order by b.user_id, IFNULL(a.priority, '0') desc, old_date";
     } elseif ($tickets_due_flag == 'all') {
         $query = "SELECT a.id, a.type, b.user_id\n                      FROM healingcrystals_project_objects a\n                      inner join healingcrystals_assignments b on a.id=b.object_id\n                      left outer join healingcrystals_project_object_misc c on (a.id=c.object_id)\n                      where a.state='" . STATE_VISIBLE . "' and b.user_id='" . $user_id . "' and b.is_owner='1' and\n                      (a.type='Task' or a.type='Ticket') and (a.completed_on is null or a.completed_on='') and\n                      a.due_on is not null\n                      order by b.user_id, IFNULL(a.priority, '0') desc";
     }
     if (!empty($query)) {
         $result = mysql_query($query, $link);
         $tickets_due_info = array();
         if (mysql_num_rows($result)) {
             while ($entry = mysql_fetch_assoc($result)) {
                 $tickets_due_info[] = array('type' => $entry['type'], 'id' => $entry['id'], 'reminder' => $entry['reminder_date']);
             }
         }
     }
     $query = "(select b.id, d.id as parent_ref , a.date_added as date_value, e.priority as prio, c.name as project_name\n\t\t from healingcrystals_assignments_action_request a\n\t\t inner join healingcrystals_project_objects b on a.comment_id=b.id\n\t\t inner join healingcrystals_project_objects d on b.parent_id=d.id\n\t\t left outer join healingcrystals_project_objects e on d.milestone_id=e.id\n\t\t inner join healingcrystals_projects c on b.project_id=c.id\n\t\t where b.state='" . STATE_VISIBLE . "' and a.user_id='" . $user_id . "' and a.is_action_request='1'\n                 and d.state='" . STATE_VISIBLE . "'  )\n                 union\n                 (select '' as id, a.object_id as parent_ref, b.created_on as date_value, e.priority as prio, c.name as project_name\n                 from healingcrystals_assignments_flag_fyi_actionrequest a\n                 inner join healingcrystals_project_objects b on a.object_id=b.id\n                 left outer join healingcrystals_project_objects e on b.milestone_id=e.id\n                 inner join healingcrystals_projects c on b.project_id=c.id\n                 where a.user_id='" . $user_id . "' and flag_actionrequest='1' and b.state='" . STATE_VISIBLE . "'\n                  )\n\t\t order by prio desc, project_name, date_value desc";
     //EOF:mod 20111103 #462
     $result = mysql_query($query, $link);
     $action_request_info = array();
     if (mysql_num_rows($result)) {
         while ($entry = mysql_fetch_assoc($result)) {
             if ($layout_type == 'summary') {
                 if (!array_key_exists((string) $entry['parent_ref'], $action_request_info)) {
                     $action_request_info[(string) $entry['parent_ref']] = array();
                 }
                 $action_request_info[(string) $entry['parent_ref']][] = $entry['id'];
             } else {
                 //BOF:mod 20111019 #448
                 if (empty($entry['id'])) {
                     $action_request_info[] = $entry['parent_ref'];
                 } else {
                     //EOF:mod 20111019 #448
                     $action_request_info[] = $entry['id'];
                     //BOF:mod 20111019
                 }
                 //EOF:Mod 20111019
             }
         }
     }
     $query = "(select b.id, d.id as parent_ref , a.date_added as date_value, e.priority as prio, c.name as project_name\n\t\t from healingcrystals_assignments_action_request a\n\t\t inner join healingcrystals_project_objects b on a.comment_id=b.id\n\t\t inner join healingcrystals_project_objects d on b.parent_id=d.id\n\t\t left outer join healingcrystals_project_objects e on d.milestone_id=e.id\n\t\t inner join healingcrystals_projects c on b.project_id=c.id\n\t\t where b.state='" . STATE_VISIBLE . "' and a.user_id='" . $user_id . "' and a.is_fyi='1'\n                 and d.state='" . STATE_VISIBLE . "' )\n                 union\n                 (select '' as id, a.object_id as parent_ref, b.created_on as date_value, e.priority as prio, c.name as project_name\n                 from healingcrystals_assignments_flag_fyi_actionrequest a\n                 inner join healingcrystals_project_objects b on a.object_id=b.id\n                 left outer join healingcrystals_project_objects e on b.milestone_id=e.id\n                 inner join healingcrystals_projects c on b.project_id=c.id\n                 where a.user_id='" . $user_id . "' and flag_fyi='1' and b.state='" . STATE_VISIBLE . "'\n                  )\n\t\t order by prio desc, project_name, date_value desc";
     //EOF:mod 20111103 #462
     $result = mysql_query($query, $link);
     $info = array();
     if (mysql_num_rows($result)) {
         while ($entry = mysql_fetch_assoc($result)) {
             if ($layout_type == 'summary') {
                 if (!array_key_exists((string) $entry['parent_ref'], $info)) {
                     $info[(string) $entry['parent_ref']] = array();
                 }
                 $info[(string) $entry['parent_ref']][] = $entry['id'];
             } else {
                 //BOF:mod 20111019 #448
                 if (empty($entry['id'])) {
                     $info[] = $entry['parent_ref'];
                 } else {
                     //EOF:mod 20111019 #448
                     $info[] = $entry['id'];
                     //BOF:mod 20111019
                 }
                 //EOF:Mod 20111019
             }
         }
     }
     $search_from = time() - 24 * 60 * 60;
     $query = "SELECT a.id, b.user_id FROM healingcrystals_project_objects a\n                 inner join healingcrystals_assignments b on a.id=b.object_id\n\t\t where a.state='" . STATE_VISIBLE . "' and b.user_id='" . $user_id . "' and a.type='Ticket' and a.completed_on is not null and\n\t\t a.completed_on >= '" . date('Y-m-d H:i', $search_from) . "' order by b.user_id, a.due_on";
     $result = mysql_query($query, $link);
     $completed_objects = array();
     if (mysql_num_rows($result)) {
         while ($entry = mysql_fetch_assoc($result)) {
             $query02 = "select max(id) as comment_id from healingcrystals_project_objects where parent_id='" . $entry['id'] . "' and parent_type='Ticket' and type='Comment'";
             $result02 = mysql_query($query02);
             if (mysql_num_rows($result02)) {
                 $comment_info = mysql_fetch_assoc($result02);
             }
             $completed_objects[] = array('ticket_id' => $entry['id'], 'last_comment_id' => $comment_info['comment_id']);
         }
     }
     $fyi_updates = array();
     $query = "select id, fyi_user_id, object_id from healingcrystals_project_objects_to_fyi_users where fyi_user_id='" . $user_id . "' and user_intimated_on is null";
     $result = mysql_query($query);
     if (mysql_num_rows($result)) {
         while ($entry = mysql_fetch_assoc($result)) {
             $fyi_updates[] = $entry['object_id'];
         }
     }
     $fyi_table_start = '
             <a name="fyi"></a>
             <table style="border:1px solid black;">
                 <tr>
                     <td colspan="4">&nbsp;</td>
                 </tr>' . (count($info) ? '
                 <tr>
                     <th colspan="4">FYI Comment(s)</th>
                 </tr>
                 <tr>
                     <td colspan="4">&nbsp;</td>
                 </tr>' : '');
     $fyi_table_end = '
             </table>';
     $action_request_table_start = '
             <a name="action_request"></a>
             <table style="border:1px solid black;">
                 <tr>
                     <td colspan="4">&nbsp;</td>
                 </tr>' . (count($action_request_info) ? '
                 <tr>
                     <th colspan="4">Action Request Comment(s)</th>
                 </tr>
                 <tr>
                     <td colspan="4">&nbsp;</td>
                 </tr>' : '');
     $action_request_table_end = '
             </table>';
     $completed_objects_table_start = '
             <a name="closed_tickets"></a>
             <table style="border:1px solid black;">
                 <tr>
                     <td colspan="2">&nbsp;</td>
                 </tr>' . (count($completed_objects) ? '
                 <tr>
                     <th colspan="2">Recently Closed Tickets</th>
                 </tr>
                 <tr>
                     <td colspan="2">&nbsp;</td>
                 </tr>' : '');
     $completed_objects_table_end = '
             </table>';
     $fyi_updates_table_start = '
             <table style="border:1px solid black;">
                 <tr>
                     <td colspan="2">&nbsp;</td>
                 </tr>' . (count($fyi_updates) ? '
                 <tr>
                     <th colspan="2">FYI Updates</th>
                 </tr>
                 <tr>
                     <td colspan="2">&nbsp;</td>
                 </tr>' : '');
     $fyi_updates_table_end = '
             </table>';
     $tickets_due_table_start = '
             <a name="tickets_due"></a>
             <table style="border:1px solid black;">
                 <tr><td colspan="4">&nbsp;</td></tr>
                 <tr>
                     <th colspan="4">
                         Due Tickets & Tasks:
                         <div style="float:right;font-weight:normal;">
                             <table cellspacing="0" cellpadding="0">
                                 <tr>
                                     <td valign="middle">
                                         <input type="radio" onclick="location.href=\'' . assemble_url('goto_home_tab') . '&due_flag=due\'" name="objects_due" value="due" style="width:20px;" ' . ($tickets_due_flag == 'due' ? ' checked="true"' : '') . ' />
                                     </td>
                                     <td valign="middle">Show Due Dates/Reminders</td>
                                     <td valign="middle">&nbsp;&nbsp;&nbsp;</td>
                                     <td valign="middle">
                                         <input type="radio" onclick="location.href=\'' . assemble_url('goto_home_tab') . '&due_flag=all\'" name="objects_due" value="all" style="width:20px;" ' . ($tickets_due_flag == 'all' ? ' checked="true"' : '') . ' />
                                     </td>
                                     <td valign="middle">Show All Tickets & Tasks</td>
                                 </tr>
                             </table>
                         </div>
                     </th>
                 </tr>
                 <tr><td colspan="4">&nbsp;</td></tr>
                 <tr>
                     <th align="left">Type</th>
                     <th align="left">Name</th>
                     <th align="left">Priority</th>
                     <th align="left">' . ($tickets_due_flag == 'due' ? 'Due on / Reminder' : 'Due on') . '</th>
                 </tr>';
     $tickets_due_table_end = '
             </table>';
     $tickets_due_content = '';
     if ($tickets_due_info && is_array($tickets_due_info)) {
         foreach ($tickets_due_info as $entry) {
             $type = $entry['type'];
             $obj = new $type($entry['id']);
             $due_date_val = $obj->getDueOn();
             if (!empty($due_date_val)) {
                 $due_date = date('F d, Y', strtotime($obj->getDueOn()));
             } else {
                 $due_date = '--';
             }
             if (!empty($entry['reminder']) && $entry['reminder'] != '0000-00-00') {
                 $reminder_date = date('F d, Y', strtotime($entry['reminder']));
             } else {
                 $reminder_date = '--';
             }
             if ($tickets_due_flag == 'due') {
                 $date_string = $due_date . ' / ' . $reminder_date;
             } else {
                 $date_string = $due_date;
             }
             $tickets_due_content .= '
                 <tr>
                     <td>' . $type . '</td>
                     <td>
                         <a target="_blank" href="' . $obj->getViewUrl() . '">
                             <span class="homepageobject">' . strip_tags($obj->getName()) . '</span>
                         </a>
                     </td>
                     <td>' . $obj->getFormattedPriority() . '</td>
                     <td> ' . $date_string . '</td>
                 </tr>';
             unset($obj);
         }
     } else {
         $tickets_due_content .= '
             <tr>
                 <td colspan="4">No Records to Display</td>
             </tr>';
     }
     $fyi_comments_unvisited = 0;
     $content = '';
     if ($info && is_array($info)) {
         if ($layout_type == 'summary') {
             foreach ($info as $ticket_id => $comments) {
                 //BOF:mod 20111019 #448
                 if (!empty($comments[0])) {
                     //EOF:mod 20111019 #448
                     $temp_obj = new Comment($comments[0]);
                     $parenttype = $temp_obj->getParentType();
                     //BOF:mod 20111019 #448
                 } else {
                     $temp_obj = new ProjectObject($ticket_id);
                     $parenttype = $temp_obj->getType();
                 }
                 //EOF:mod 20111019 #448
                 $parentobj = new $parenttype($ticket_id);
                 $comment_links = '';
                 //$comment_info = '';
                 $count = 0;
                 //$max_chars = 1000;
                 foreach ($comments as $comment_id) {
                     $count++;
                     //BOF:mod 20111019 #448
                     if (!empty($comment_id)) {
                         //EOF:mod 20111019 #448
                         $temp_obj = new Comment($comment_id);
                         $is_unvisited = $this->link_unvisited($temp_obj->getId());
                         if ($is_unvisited) {
                             $fyi_comments_unvisited++;
                         }
                         $comment_links .= '<a target="_blank" href="' . $temp_obj->getViewUrl() . '" class="anc01' . (!$is_unvisited ? '_visited' : '') . '">#' . $count . '</a>&nbsp;&nbsp;&nbsp;';
                         //BOF:mod 20111019 #448
                     } else {
                         $is_unvisited = $this->link_unvisited($temp_obj->getId());
                         if ($is_unvisited) {
                             $fyi_comments_unvisited++;
                         }
                         $comment_links .= '<a target="_blank" href="' . $parentobj->getViewUrl() . '" class="anc01' . (!$is_unvisited ? '_visited' : '') . '">#' . $count . '</a>&nbsp;&nbsp;&nbsp;';
                     }
                     //EOF:mod 20111019 #448
                 }
                 $content .= '
                     <tr>
                         <td vlaign="top" class="comment_link" colspan="4">
                             &nbsp;&nbsp;&nbsp;
                             <a target="_blank" href="' . $parentobj->getViewUrl() . '">
                                <span class="homepageobject">' . $parentobj->getName() . '</span>
                             </a>
                             &nbsp;&nbsp;&nbsp;' . $comment_links . '<span id="fyi_' . $parentobj->getId() . '"><img id="icon_plus" src="' . ROOT_URL . '/assets/images/icons/icon_plus.png" hspace="0" vspace="0" border="0" style="cursor:pointer;" /></span>
                         </td>
                     </tr>';
             }
         } else {
             foreach ($info as $comment_id) {
                 //BOF:mod 20111019 #448
                 $temp_obj = new ProjectObject($comment_id);
                 $temp_type = $temp_obj->getType();
                 if ($temp_type == 'Comment') {
                     //EOF:mod 20111019 #448
                     $obj = new Comment($comment_id);
                     //BOF:mod 20111019 #448
                     $is_comment_obj = true;
                 } else {
                     $obj = new $temp_type($comment_id);
                     $is_comment_obj = false;
                 }
                 //EOF:mod 20111019 #448
                 $is_unvisited = $this->link_unvisited($obj->getId());
                 if ($is_unvisited) {
                     $fyi_comments_unvisited++;
                 }
                 $created_by_id = $obj->getCreatedById();
                 $created_by_user = new User($created_by_id);
                 $created_on = strtotime($obj->getCreatedOn());
                 $created_on = date('m-d-y', $created_on);
                 $projectobj = new Project($obj->getProjectId());
                 $parenttype = $obj->getParentType();
                 //BOF:mod 20111019 #448
                 if ($is_comment_obj) {
                     //EOF:mod 20111019 #448
                     $parentobj = new $parenttype($obj->getParentId());
                     //BOF:mod 20111019 #448
                 } else {
                     $parentobj = $obj;
                 }
                 //EOF:mod 20111019 #448
                 $milestone_id = $parentobj->getMilestoneId();
                 if (!empty($milestone_id)) {
                     $milestoneobj = new Milestone($milestone_id);
                 }
                 $assigneesstring = '';
                 list($assignees, $owner_id) = $parentobj->getAssignmentData();
                 foreach ($assignees as $assignee) {
                     $assigneeobj = new User($assignee);
                     $assigneesstring .= '<a target="_blank" href="' . $assigneeobj->getViewUrl() . '">' . $assigneeobj->getName() . '</a>, ';
                     unset($assigneeobj);
                 }
                 if (!empty($assigneesstring)) {
                     $assigneesstring = substr($assigneesstring, 0, -2);
                 }
                 $dueon = date('F d, Y', strtotime($parentobj->getDueOn()));
                 if ($dueon == 'January 01, 1970') {
                     $dueon = '--';
                 }
                 if ($milestoneobj) {
                     $priority = $milestoneobj->getPriority();
                     if (!empty($priority) || $priority == '0') {
                         $priority = $milestoneobj->getFormattedPriority();
                     } else {
                         $priority = '--';
                     }
                 } else {
                     $priority = '--';
                 }
                 $max_chars = 1000;
                 $temp = $obj->getFormattedBody(true, true);
                 $comment_body = $temp;
                 $content .= '
                     <tr>
                         <td valign="top" width="150">Ticket</td>
                         <td valign="top">
                             <a target="_blank" href="' . $parentobj->getViewUrl() . '">' . $parentobj->getName() . '</a>
                         </td>
                     </tr>
                     <tr>
                         <td valign="top">Team &raquo; Project</td>
                         <td valign="top">
                             <a target="_blank" href="' . $projectobj->getOverviewUrl() . '">' . $projectobj->getName() . '</a> &raquo; ' . ($milestoneobj ? '<a target="_blank" href="' . $milestoneobj->getViewUrl() . '">' . $milestoneobj->getName() . '</a>' : '--') . '</td>
                     </tr>
                     <tr>
                         <td valign="top">Project Priority</td>
                         <td valign="top">' . $priority . '</td>
                     </tr>
                     <tr>
                         <td valign="top">Due on</td>
                         <td valign="top">' . $dueon . '</td>
                     </tr>' . (!empty($assigneesstring) ? '<tr>
                         <td valign="top">Assignees</td>
                         <td valign="top">' . $assigneesstring . '</td>
                     </tr>' : '<tr><td colpan="2"></td></tr>') . '<tr>
                         <td valign="top">' . ($is_comment_obj ? 'Comment' : 'Created') . ' by<br/>' . $created_by_user->getName() . '<br/><br/><br/><a target="_blank" href="' . $obj->getViewUrl() . '" class="anc02' . (!$is_unvisited ? '_visited' : '') . '">[view ' . ($is_comment_obj ? 'comment' : 'object') . ']</a><br/>' . $created_on . '<br/><br/><br/><a class="mark_as_read" href="' . ($is_comment_obj ? assemble_url('project_comment_fyi_read', array('project_id' => $obj->getProjectId(), 'comment_id' => $obj->getId())) : assemble_url('project_object_fyi_read', array('project_id' => $obj->getProjectId())) . '&object_id=' . $obj->getId() . '&project_id=' . $obj->getProjectId()) . '">Mark this Notification<br/>as Read</a></td>
                         <td valign="top" style="max-width:500px;"><div style="overflow:auto;">' . $obj->getBody() . '</div></td>
                     </tr>
                     <tr><td colspan="2" style="border-bottom:1px dotted #000000;">&nbsp;</td></tr>
                     <tr><td colspan="2">&nbsp;</td></tr>';
             }
         }
         unset($obj);
         unset($projectobj);
         unset($parentobj);
         unset($milestone_id);
         unset($milestoneobj);
         unset($assignees);
         unset($owner_id);
     }
     $action_request_content = '';
     $action_request_comments_unvisited = 0;
     if ($action_request_info && is_array($action_request_info)) {
         if ($layout_type == 'summary') {
             foreach ($action_request_info as $ticket_id => $comments) {
                 //BOF:mod 20111019 #448
                 if (!empty($comments[0])) {
                     //EOF:mod 20111019 #448
                     $temp_obj = new Comment($comments[0]);
                     $parenttype = $temp_obj->getParentType();
                     //BOF:mod 20111019 #448
                 } else {
                     $temp_obj = new ProjectObject($ticket_id);
                     $parenttype = $temp_obj->getType();
                 }
                 //EOF:mod 20111019 #448
                 $parentobj = new $parenttype($ticket_id);
                 $comment_links = '';
                 //$comment_info = '';
                 $count = 0;
                 //$max_chars = 1000;
                 foreach ($comments as $comment_id) {
                     $count++;
                     //BOF:mod 20111019 #448
                     if (!empty($comment_id)) {
                         //EOF:mod 20111019 #448
                         $temp_obj = new Comment($comment_id);
                         $is_unvisited = $this->link_unvisited($temp_obj->getId());
                         if ($is_unvisited) {
                             $action_request_comments_unvisited++;
                         }
                         $comment_links .= '<a target="_blank" href="' . $temp_obj->getViewUrl() . '" class="anc01' . (!$is_unvisited ? '_visited' : '') . '">#' . $count . '</a>&nbsp;&nbsp;&nbsp;';
                         //BOF:mod 20111019 #448
                     } else {
                         $is_unvisited = $this->link_unvisited($temp_obj->getId());
                         if ($is_unvisited) {
                             $action_request_comments_unvisited++;
                         }
                         $comment_links .= '<a target="_blank" href="' . $parentobj->getViewUrl() . '" class="anc01' . (!$is_unvisited ? '_visited' : '') . '">#' . $count . '</a>&nbsp;&nbsp;&nbsp;';
                     }
                     //EOF:mod 20111019 #448
                 }
                 $action_request_content .= '
                     <tr>
                         <td vlaign="top" class="comment_link" colspan="4">
                             &nbsp;&nbsp;&nbsp;
                             <a target="_blank" href="' . $parentobj->getViewUrl() . '">
                                 <span class="homepageobject">' . $parentobj->getName() . '</span>
                             </a>
                             &nbsp;&nbsp;&nbsp;' . $comment_links . '<span id="action_' . $parentobj->getId() . '"><img id="icon_plus" src="' . ROOT_URL . '/assets/images/icons/icon_plus.png" hspace="0" vspace="0" border="0" style="cursor:pointer;" /></span>
                         </td>
                     </tr>';
             }
         } else {
             foreach ($action_request_info as $comment) {
                 //BOF:mod 20111019 #448
                 $temp_obj = new ProjectObject($comment);
                 $temp_type = $temp_obj->getType();
                 if ($temp_type == 'Comment') {
                     //EOF:mod 20111019 #448
                     $obj = new Comment($comment);
                     //BOF:mod 20111019 #448
                     $is_comment_obj = true;
                 } else {
                     $obj = new $temp_type($comment);
                     $is_comment_obj = false;
                 }
                 //EOF:mod 20111019 #448
                 $is_unvisited = $this->link_unvisited($obj->getId());
                 if ($is_unvisited) {
                     $action_request_comments_unvisited++;
                 }
                 $created_by_id = $obj->getCreatedById();
                 $created_by_user = new User($created_by_id);
                 $created_on = strtotime($obj->getCreatedOn());
                 $created_on = date('m-d-y', $created_on);
                 $projectobj = new Project($obj->getProjectId());
                 $parenttype = $obj->getParentType();
                 //BOF:mod 20111019 #448
                 if ($is_comment_obj) {
                     //EOF:mod 20111019 #448
                     $parentobj = new $parenttype($obj->getParentId());
                     //BOF:mod 20111019 #448
                 } else {
                     $parentobj = $obj;
                 }
                 //EOF:mod 20111019 #448
                 $milestone_id = $parentobj->getMilestoneId();
                 if (!empty($milestone_id)) {
                     $milestoneobj = new Milestone($milestone_id);
                 }
                 $assigneesstring = '';
                 list($assignees, $owner_id) = $parentobj->getAssignmentData();
                 foreach ($assignees as $assignee) {
                     $assigneeobj = new User($assignee);
                     $assigneesstring .= '<a target="_blank" href="' . $assigneeobj->getViewUrl() . '">' . $assigneeobj->getName() . '</a>, ';
                     unset($assigneeobj);
                 }
                 if (!empty($assigneesstring)) {
                     $assigneesstring = substr($assigneesstring, 0, -2);
                 }
                 $dueon = date('F d, Y', strtotime($parentobj->getDueOn()));
                 if ($dueon == 'January 01, 1970') {
                     $dueon = '--';
                 }
                 if ($milestoneobj) {
                     $priority = $milestoneobj->getPriority();
                     if (!empty($priority) || $priority == '0') {
                         $priority = $milestoneobj->getFormattedPriority();
                     } else {
                         $priority = '--';
                     }
                 } else {
                     $priority = '--';
                 }
                 $max_chars = 1000;
                 $temp = $obj->getFormattedBody(true, true);
                 $comment_body = $temp;
                 /*$comment_body = trim(str_excerpt(smarty_modifier_html_excerpt($temp), $max_chars));
                   if (strlen($temp)>$max_chars){
                       $show_read_link = true;
                   } else {
                       $show_read_link = false;
                   }*/
                 $action_request_content .= '
                     <tr>
                         <td valign="top" width="150">Ticket</td>
                         <td valign="top">
                             <a target="_blank" href="' . $parentobj->getViewUrl() . '">' . $parentobj->getName() . '</a>
                         </td>
                     </tr>
                     <tr>
                         <td valign="top">Team &raquo; Project</td>
                         <td valign="top"><a target="_blank" href="' . $projectobj->getOverviewUrl() . '">' . $projectobj->getName() . '</a> &raquo; ' . ($milestoneobj ? '<a target="_blank" href="' . $milestoneobj->getViewUrl() . '">' . $milestoneobj->getName() . '</a>' : '--') . '</td>
                     </tr>
                     <tr>
                         <td valign="top">Project Priority</td>
                         <td valign="top">' . $priority . '</td>
                     </tr>
                     <tr>
                         <td valign="top">Due on</td>
                         <td valign="top">' . $dueon . '</td>
                     </tr>' . (!empty($assigneesstring) ? '<tr>
                         <td valign="top">Assignees</td>
                         <td valign="top">' . $assigneesstring . '</td>
                     </tr>' : '<tr><td colspan="2"></td></tr>') . '<tr>
                         <td valign="top">' . ($is_comment_obj ? 'Comment' : 'Created') . ' by<br/>' . $created_by_user->getName() . '<br/><br/><br/><a target="_blank" href="' . $obj->getViewUrl() . '" class="anc02' . (!$is_unvisited ? '_visited' : '') . '">[view ' . ($is_comment_obj ? 'comment' : 'object') . ']</a><br/>' . $created_on . '<br/><br/><br/><a class="mark_as_complete" href="' . ($is_comment_obj ? assemble_url('project_comment_action_request_completed', array('project_id' => $obj->getProjectId(), 'comment_id' => $obj->getId())) : assemble_url('project_object_action_request_completed', array('project_id' => $obj->getProjectId())) . '&object_id=' . $obj->getId() . '&project_id=' . $obj->getProjectId()) . '">Mark Action Request Complete</a></td>
                         <td valign="top" style="max-width:500px;"><div style="overflow:auto;">' . $obj->getBody() . '</div></td>
                     </tr>
                     <tr><td colspan="2" style="border-bottom:1px dotted #000000;">&nbsp;</td></tr>
                     <tr><td colspan="2">&nbsp;</td></tr>';
             }
         }
         unset($obj);
         unset($projectobj);
         unset($parentobj);
         unset($milestone_id);
         unset($milestoneobj);
         unset($assignees);
         unset($owner_id);
     }
     $completed_objects_content = '';
     if ($completed_objects && is_array($completed_objects)) {
         foreach ($completed_objects[(string) $userid] as $entry) {
             $obj = new Ticket($entry['ticket_id']);
             $projectobj = new Project($obj->getProjectId());
             $milestone_id = $obj->getMilestoneId();
             if (!empty($milestone_id)) {
                 $milestoneobj = new Milestone($milestone_id);
             }
             $assigneesstring = '';
             list($assignees, $owner_id) = $obj->getAssignmentData();
             foreach ($assignees as $assignee) {
                 $assigneeobj = new User($assignee);
                 $assigneesstring .= '<a target="_blank" href="' . $assigneeobj->getViewUrl() . '">' . $assigneeobj->getName() . '</a>, ';
                 unset($assigneeobj);
             }
             if (!empty($assigneesstring)) {
                 $assigneesstring = substr($assigneesstring, 0, -2);
             }
             $completedon = date('F d, Y', strtotime($obj->getCompletedOn()));
             if (!empty($entry['last_comment_id'])) {
                 $commentobj = new Comment($entry['last_comment_id']);
                 $last_comment_body = '<br>' . $commentobj->getBody();
                 unset($commentobj);
             } else {
                 $last_comment_body = '<br>None';
             }
             $completed_objects_content .= '
                 <tr>
                     <td valign="top" width="150">' . $obj->getType() . '</td>
                     <td valign="top"><a target="_blank" href="' . $obj->getViewUrl() . '"><span class="homepageobject">' . $obj->getName() . '</span></a></td>
                 </tr>
                 <tr>
                     <td valign="top">Team &raquo; Project</td>
                     <td valign="top"><a target="_blank" href="' . $projectobj->getOverviewUrl() . '"><span class="homepageobject">' . $projectobj->getName() . '</span></a> &raquo; ' . ($milestoneobj ? '<a target="_blank" href="' . $milestoneobj->getViewUrl() . '"><span class="homepageobject">' . $milestoneobj->getName() . '</span></a>' : '--') . '</td>
                 </tr>
                 <tr>
                     <td valign="top">Completed on</td>
                     <td valign="top">' . $completedon . '</td>
                 </tr>' . (!empty($assigneesstring) ? '<tr>
                     <td valign="top">Assignees</td>
                     <td valign="top">' . $assigneesstring . '</td>
                 </tr>' : '') . '<tr>
                     <td valign="top">&nbsp;</td>
                     <td valign="top" style="max-width:500px;"><div style="overflow:auto;">' . $obj->getBody() . '</div></td>
                 </tr>
                 <tr><td colspan="2">&nbsp;</td></tr>
                 <tr>
                     <td valign="top">&nbsp;</td>
                     <td valign="top"><b>Last comment associated with the ticket:</b><br>' . $last_comment_body . '</td>
                 </tr>
                 <tr><td colspan="2" style="border-bottom:1px dotted #000000;">&nbsp;</td></tr>
                 <tr><td colspan="2">&nbsp;</td></tr>';
             unset($obj);
             unset($projectobj);
             unset($milestone_id);
             unset($milestoneobj);
             unset($assignees);
             unset($owner_id);
         }
     }
     $fyi_updates_content = '';
     if ($fyi_updates && is_array($fyi_updates)) {
         foreach ($fyi_updates[(string) $userid] as $object_id) {
             $baseobj = new ProjectObject($object_id);
             $type = $baseobj->getType();
             switch ($baseobj->getType()) {
                 case 'Page':
                     $obj = new Page($object_id);
                     break;
             }
             if ($obj) {
                 $projectobj = new Project($obj->getProjectId());
                 $milestone_id = $obj->getMilestoneId();
                 if (!empty($milestone_id)) {
                     $milestoneobj = new Milestone($milestone_id);
                 }
                 $subscribers = $obj->getSubscribers();
                 foreach ($subscribers as $subscriber) {
                     $subscriberstring .= '<a target="_blank" href="' . $subscriber->getViewUrl() . '">' . $subscriber->getName() . '</a>, ';
                 }
                 if (!empty($subscriberstring)) {
                     $subscriberstring = substr($subscriberstring, 0, -2);
                 }
                 $fyi_updates_content .= '
             <tr>
                 <td valign="top" width="150">' . $obj->getType() . '</td>
                 <td valign="top"><a target="_blank" href="' . $obj->getViewUrl() . '"><span class="homepageobject">' . $obj->getName() . '</span></a></td>
             </tr>
             <tr>
                 <td valign="top">Team &raquo; Project</td>
                 <td valign="top"><a target="_blank" href="' . $projectobj->getOverviewUrl() . '"><span class="homepageobject">' . $projectobj->getName() . '</span></a> &raquo; ' . ($milestoneobj ? '<a target="_blank" href="' . $milestoneobj->getViewUrl() . '"><span class="homepageobject">' . $milestoneobj->getName() . '</span></a>' : '--') . '</td>
             </tr>' . (!empty($subscriberstring) ? '<tr>
                 <td valign="top">Subscribers</td>
                 <td valign="top">' . $subscriberstring . '</td>
             </tr>' : '') . '<tr>
                 <td valign="top">&nbsp;</td>
                 <td valign="top" style="max-width:500px;"><div style="overflow:auto;">' . $obj->getBody() . '</div></td>
             </tr>
             <tr><td colspan="2" style="border-bottom:1px dotted #000000;">&nbsp;</td></tr>
             <tr><td colspan="2">&nbsp;</td></tr>';
             }
             unset($obj);
             unset($projectobj);
             unset($milestoneobj);
         }
     }
     $home_tab_content = '';
     if (!empty($tickets_due_content)) {
         $home_tab_content .= $tickets_due_table_start . $tickets_due_content . $tickets_due_table_end . '<br/><br/>';
         $goto_links .= '<a href="#tickets_due">Go to Due Tickets & Tasks</a><br/>';
     }
     if (!empty($action_request_content)) {
         $home_tab_content .= $action_request_table_start . $action_request_content . $action_request_table_end . '<br/><br/>';
         $goto_links .= '<a href="#action_request">Go to Action Request Comment(s)</a><br/>';
     }
     if (!empty($content)) {
         $home_tab_content .= $fyi_table_start . $content . $fyi_table_end . '<br/><br/>';
         $goto_links .= '<a href="#fyi">Go to FYI Comment(s)</a><br/>';
     }
     if (!empty($fyi_updates_content)) {
         $home_tab_content .= $fyi_updates_table_start . $fyi_updates_content . $fyi_updates_table_end . '<br/><br/>';
     }
     if (!empty($completed_objects_content)) {
         $home_tab_content .= $completed_objects_table_start . $completed_objects_content . $completed_objects_table_end;
         $goto_links .= '<a href="#closed_tickets">Go to Closed Ticket(s)</a><br/>';
     }
     if (!empty($goto_links)) {
         $goto_links .= '<br/><br/>';
     }
     $goto_links .= '<input type="hidden" id="unvisited_fyi_comments" value="' . $fyi_comments_unvisited . '" />
                    <input type="hidden" id="unvisited_action_request_comments" value="' . $action_request_comments_unvisited . '" />
                    <input type="hidden" id="user_id" value="' . $user_id . '" />';
     $css = '
             <style>
                 td a.anc01_visited, td a.anc02_visited {color:#FF00FF;}
                 body {}
                 span.homepageobject {}
                 table tr {line-height:1.5;}:
             </style>';
     $home_tab_content = $css . $top_message . '<br/><br/>' . $goto_links . $home_tab_content;
     mysql_close($link);
     return $home_tab_content;
 }
Example #19
0
 /**
  * Gets the current project name from the user's project cookie. If no project ID is set it will redirect
  * to the select project page.
  *
  * @return  string The current project name
  */
 public static function getCurrentProjectName()
 {
     return Project::getName(self::getCurrentProject(true));
 }
Example #20
0
// | Free Software Foundation, Inc.                                       |
// | 51 Franklin Street, Suite 330                                          |
// | Boston, MA 02110-1301, USA.                                          |
// +----------------------------------------------------------------------+
// | Authors: João Prado Maia <*****@*****.**>                             |
// +----------------------------------------------------------------------+
require_once dirname(__FILE__) . '/../../init.php';
$tpl = new Template_Helper();
$tpl->setTemplate('manage/issue_auto_creation.tpl.html');
Auth::checkAuthentication(APP_COOKIE);
@($ema_id = $_POST['ema_id'] ? $_POST['ema_id'] : $_GET['ema_id']);
$role_id = Auth::getCurrentRole();
if ($role_id < User::getRoleID('administrator')) {
    Misc::setMessage('Sorry, you are not allowed to access this page.', Misc::MSG_ERROR);
    $tpl->displayTemplate();
    exit;
}
$prj_id = Email_Account::getProjectID($ema_id);
if (@$_POST['cat'] == 'update') {
    @Email_Account::updateIssueAutoCreation($ema_id, $_POST['issue_auto_creation'], $_POST['options']);
}
// load the form fields
$tpl->assign('info', Email_Account::getDetails($ema_id));
$tpl->assign('cats', Category::getAssocList($prj_id));
$tpl->assign('priorities', Priority::getList($prj_id));
$tpl->assign('users', Project::getUserAssocList($prj_id, 'active'));
$tpl->assign('options', Email_Account::getIssueAutoCreationOptions($ema_id));
$tpl->assign('ema_id', $ema_id);
$tpl->assign('prj_title', Project::getName($prj_id));
$tpl->assign('uses_customer_integration', CRM::hasCustomerIntegration($prj_id));
$tpl->displayTemplate();
Example #21
0
 /**
  * Gets the current project name from the user's project cookie.
  *
  * @access  public
  * @return  string The current project name
  */
 function getCurrentProjectName()
 {
     $proj_id = Auth::getCurrentProject();
     if (!empty($proj_id)) {
         return Project::getName($proj_id);
     }
 }
Example #22
0
if (@$_POST['cat'] == 'save') {
    $res = Display_Column::save();
    $tpl->assign('result', $res);
    Misc::mapMessages($res, array(1 => array(ev_gettext('Thank you, columns to display was saved successfully.'), Misc::MSG_INFO), -1 => array(ev_gettext('An error occurred while trying to save columns to display.'), Misc::MSG_ERROR)));
}
$page = 'list_issues';
$available = Display_Column::getAllColumns($page);
$selected = Display_Column::getSelectedColumns($prj_id, $page);
// re-order available array to match rank
$available_ordered = array();
foreach ($selected as $field_name => $field_info) {
    $available_ordered[$field_name] = $available[$field_name];
    unset($available[$field_name]);
}
if (count($available) > 0) {
    $available_ordered += $available;
}
$excluded_roles = array();
if (!CRM::hasCustomerIntegration($prj_id)) {
    $excluded_roles[] = 'customer';
}
$user_roles = User::getRoles($excluded_roles);
$user_roles[9] = 'Never Display';
// generate ranks
$ranks = array();
$navailable_ordered = count($available_ordered);
for ($i = 1; $i <= $navailable_ordered; $i++) {
    $ranks[$i] = $i;
}
$tpl->assign(array('available' => $available_ordered, 'selected' => $selected, 'user_roles' => $user_roles, 'page' => $page, 'ranks' => $ranks, 'prj_id' => $prj_id, 'project_name' => Project::getName($prj_id)));
$tpl->displayTemplate();
Example #23
0
 /**
  * @param Project $project
  * @return \ActivityLog
  */
 public function setProject(Project $project = NULL)
 {
     $this->project = $project;
     if ($project !== NULL) {
         $this->projectName = $project->getName();
     }
     return $this;
 }
Example #24
0
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">Support</h4>
      </div>
      <div class="modal-body">
  			  <select id="chooseReward" class="form-control">
            <option disabled selected>Select a Reward</option>
          <?php 
    foreach ($levels as $level) {
        $level = new Project($level->ID);
        ?>
             <option value="<?php 
        echo $level->getID();
        ?>
"><?php 
        echo $level->getName();
        ?>
 (<?php 
        echo "\$" . $level->getDonationAmount();
        ?>
)</option>
          <?php 
    }
    ?>
  			  </select>
          <?php 
    foreach ($levels as $level) {
        $level = new Project($level->ID);
        ?>
          <div id="supportLevel<?php 
        echo $level->getID();
Example #25
0
function jsonEncodeProject(Project $project)
{
    return sprintf('{"name":"%s","label":"%s","path":"%s","type":"%s"},', $project->getName(), $project->getLabel(), $project->getPath(), $project->getType());
}
Example #26
0
 /**
  * Print the project costs
  *
  * @param $project               Project object
  * @param $withtemplate  boolean  Template or basic item (default '')
  *
  * @return Nothing (call to classes members)
  **/
 static function showForProject(Project $project, $withtemplate = '')
 {
     global $DB, $CFG_GLPI;
     $ID = $project->fields['id'];
     if (!$project->getFromDB($ID) || !$project->can($ID, READ)) {
         return false;
     }
     $canedit = $project->can($ID, UPDATE);
     echo "<div class='center'>";
     $query = "SELECT *\n                FROM `glpi_projectcosts`\n                WHERE `projects_id` = '{$ID}'\n                ORDER BY `begin_date`";
     $rand = mt_rand();
     if ($canedit) {
         echo "<div id='viewcost" . $ID . "_{$rand}'></div>\n";
         echo "<script type='text/javascript' >\n";
         echo "function viewAddCost" . $ID . "_{$rand}() {\n";
         $params = array('type' => __CLASS__, 'parenttype' => 'Project', 'projects_id' => $ID, 'id' => -1);
         Ajax::updateItemJsCode("viewcost" . $ID . "_{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params);
         echo "};";
         echo "</script>\n";
         echo "<div class='center firstbloc'>" . "<a class='vsubmit' href='javascript:viewAddCost" . $ID . "_{$rand}();'>";
         echo __('Add a new cost') . "</a></div>\n";
     }
     $total = 0;
     if ($result = $DB->query($query)) {
         echo "<table class='tab_cadre_fixehov'>";
         echo "<tr class='noHover'><th colspan='5'>" . self::getTypeName($DB->numrows($result)) . "</th></tr>";
         if ($DB->numrows($result)) {
             echo "<tr><th>" . __('Name') . "</th>";
             echo "<th>" . __('Begin date') . "</th>";
             echo "<th>" . __('End date') . "</th>";
             echo "<th>" . __('Budget') . "</th>";
             echo "<th>" . __('Cost') . "</th>";
             echo "</tr>";
             Session::initNavigateListItems(__CLASS__, sprintf(__('%1$s = %2$s'), Project::getTypeName(1), $project->getName()));
             while ($data = $DB->fetch_assoc($result)) {
                 echo "<tr class='tab_bg_2' " . ($canedit ? "style='cursor:pointer' onClick=\"viewEditCost" . $data['projects_id'] . "_" . $data['id'] . "_{$rand}();\"" : '') . ">";
                 $name = empty($data['name']) ? sprintf(__('%1$s (%2$s)'), $data['name'], $data['id']) : $data['name'];
                 echo "<td>";
                 printf(__('%1$s %2$s'), $name, Html::showToolTip($data['comment'], array('display' => false)));
                 if ($canedit) {
                     echo "\n<script type='text/javascript' >\n";
                     echo "function viewEditCost" . $data['projects_id'] . "_" . $data["id"] . "_{$rand}() {\n";
                     $params = array('type' => __CLASS__, 'parenttype' => 'Project', 'projects_id' => $data["projects_id"], 'id' => $data["id"]);
                     Ajax::updateItemJsCode("viewcost" . $ID . "_{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params);
                     echo "};";
                     echo "</script>\n";
                 }
                 echo "</td>";
                 echo "<td>" . Html::convDate($data['begin_date']) . "</td>";
                 echo "<td>" . Html::convDate($data['end_date']) . "</td>";
                 echo "<td>" . Dropdown::getDropdownName('glpi_budgets', $data['budgets_id']) . "</td>";
                 echo "<td class='numeric'>" . Html::formatNumber($data['cost']) . "</td>";
                 $total += $data['cost'];
                 echo "</tr>";
                 Session::addToNavigateListItems(__CLASS__, $data['id']);
             }
             echo "<tr class='b noHover'><td colspan='3'>&nbsp;</td>";
             echo "<td class='right'>" . __('Total cost') . '</td>';
             echo "<td class='numeric'>" . Html::formatNumber($total) . '</td></tr>';
         } else {
             echo "<tr><th colspan='5'>" . __('No item found') . "</th></tr>";
         }
         echo "</table>";
     }
     echo "</div>";
     echo "<div>";
     $ticketcost = TicketCost::showForObject($project);
     echo "</div>";
     echo "<div class='b'>";
     printf(__('%1$s: %2$s'), __('Total cost'), $total + $ticketcost);
     echo "</div>";
 }
        }
        $newStatus = filter_var($_POST['state'], FILTER_SANITIZE_STRING);
        $reason = filter_var($_POST['reason'], FILTER_SANITIZE_STRING);
        if ($newStatus != $project->getState() && $project->canTransitionStates($project->getState(), $newStatus)) {
            $project->setState($newStatus);
            $project->store();
            if ($reason != '') {
                $reason = ' with the reason \'' . $reason . "'";
            }
            // log the update
            $project->submitLog('Status changed to ' . $project->getState() . $reason, $user->getId());
            if ($project->getState() != 'Archived') {
                // send to mailing list
                $project->submitMailingList('Status changed to ' . $project->getState() . $reason . " by " . htmlspecialchars($user->getFullName()));
                // inform the owner
                $project->submitEmailToOwner("Dear {$projectUser->getFullName()},<br/><br/>" . "This is an automatic email to let you know your project {$project->getName()} has been updated with status {$project->getState()}{$reason}.<br/><br/>" . "If you have any questions or concerns regarding this change you can discuss this with members on the <a href=\"{$project->getMailingListURL()}\">Mailing List</a>.<br/><br/>" . "Best,<br/>Monkeys in the machine");
            }
        }
        fURL::redirect("/storage/list.php");
    } catch (fValidationException $e) {
        echo $e->printMessage();
    } catch (fSQLException $e) {
        echo '<div class="alert alert-danger">An unexpected error occurred, please try again later</div>';
    }
}
?>

<?php 
if ($user->getId() == $project->getUserId() && ($project->getState() == 'Pending Approval' || $project->getState() == 'Unapproved')) {
    ?>
	<small class="edit_bttn">
Example #28
0
 public function equals(Project $other)
 {
     return $this->getName() == $other->getName() && $this->getUnique() == $this->getUnique();
 }
require './header.php';
$cards = fRecordSet::build('Card', array('uid=' => $_GET['cardid']));
if ($cards->count() == 0) {
    fURL::redirect("/kiosk/addcard.php?cardid=" . $_GET['cardid']);
}
$card = $cards->getRecord(0);
$user = new User($card->getUserId());
$user->load();
if (isset($_POST['print'])) {
    $project = new Project($_POST['print']);
    $project->load();
    if ($project->getUserId() != $user->getId()) {
        print "Incorrect project ID";
        exit;
    }
    $data = array('storage_id' => $project->getId(), 'name' => $project->getName(), 'ownername' => $user->getFullName(), 'more_info' => $project->getDescription(), 'completion_date' => $project->getToDate()->format('Y/m/d'), 'max_extention' => "14");
    $data_string = json_encode($data);
    $ch = curl_init('http://kiosk.london.hackspace.org.uk:12345/print/dnh');
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($data_string)));
    $result = curl_exec($ch);
    curl_close($ch);
    echo "<p>Your sticker is being printed now.</p>";
}
$projects = fRecordSet::build('Project', array('state_id!=' => array('6', '7'), 'user_id=' => $user->getId()));
?>

<?php 
if ($projects->count() > 0) {
Example #30
0
 /**
  * Method used as a callback to send notification events to the proper
  * recipients.
  *
  * @access  public
  * @param   resource $irc The IRC connection handle
  * @return  void
  */
 public function notifyEvents(&$irc)
 {
     // check the message table
     $stmt = "SELECT\n                    ino_id,\n                    ino_iss_id,\n                    ino_prj_id,\n                    ino_message,\n                    ino_target_usr_id,\n                    ino_category\n                 FROM\n                    {{%irc_notice}}\n                 LEFT JOIN\n                    {{%issue}}\n                 ON\n                    iss_id=ino_iss_id\n                 WHERE\n                    ino_status='pending'";
     $res = DB_Helper::getInstance()->getAll($stmt);
     for ($i = 0; $i < count($res); $i++) {
         if (empty($res[$i]['ino_category'])) {
             $res[$i]['ino_category'] = APP_EVENTUM_IRC_CATEGORY_DEFAULT;
         }
         // check if this is a targeted message
         if (!empty($res[$i]['ino_target_usr_id'])) {
             $nick = $this->_getNicknameByUser($res[$i]['ino_target_usr_id']);
             if (!empty($nick)) {
                 $this->sendResponse($irc, $nick, $res[$i]['ino_message']);
             }
             $this->_markEventSent($res[$i]['ino_id']);
             continue;
         }
         $channels = $this->_getChannels($res[$i]['ino_prj_id']);
         if (count($channels) > 0) {
             foreach ($channels as $channel => $categories) {
                 $message = $res[$i]['ino_message'];
                 if ($res[$i]['ino_iss_id'] > 0) {
                     $message .= ' - ' . APP_BASE_URL . 'view.php?id=' . $res[$i]['ino_iss_id'];
                 } elseif (substr($res[$i]['ino_message'], 0, strlen('New Pending Email')) == 'New Pending Email') {
                     $message .= ' - ' . APP_BASE_URL . 'emails.php';
                 }
                 if (count($this->_getProjectsForChannel($channel)) > 1) {
                     // if multiple projects display in the same channel, display project in message
                     $message = '[' . Project::getName($res[$i]['ino_prj_id']) . '] ' . $message;
                 }
                 if (in_array($res[$i]['ino_category'], $categories)) {
                     $this->sendResponse($irc, $channel, $message);
                 }
             }
             $this->_markEventSent($res[$i]['ino_id']);
         }
     }
 }