function taskstyle_pd($task) { $now = new CDate(); $start_date = intval($task["task_start_date"]) ? new CDate($task["task_start_date"]) : null; $end_date = intval($task["task_end_date"]) ? new CDate($task["task_end_date"]) : null; if ($start_date && !$end_date) { $end_date = $start_date; $end_date->addSeconds(@$task["task_duration"] * $task["task_duration_type"] * SEC_HOUR); } else { if (!$start_date) { return ''; } } $style = 'class='; if ($task['task_percent_complete'] == 0) { $style .= $now->before($start_date) ? '"task_future"' : '"task_notstarted"'; } else { if ($task['task_percent_complete'] == 100) { $t = new CTask(); $t->load($task['task_id']); $actual_end_date = new CDate(get_actual_end_date_pd($t->task_id, $t)); $style .= $actual_end_date->after($end_date) ? '"task_late"' : '"task_done"'; } else { $style .= $now->after($end_date) ? '"task_overdue"' : '"task_started"'; } } return $style; }
public function getProjectTaskLinksByCategory($AppUI, $project_id = 0, $task_id = 0, $category_id = 0, $search = '') { // load the following classes to retrieved denied records $project = new CProject(); $task = new CTask(); // SETUP FOR LINK LIST $q = new DBQuery(); $q->addQuery('links.*'); $q->addQuery('contact_first_name, contact_last_name'); $q->addQuery('project_name, project_color_identifier, project_status'); $q->addQuery('task_name, task_id'); $q->addTable('links'); $q->leftJoin('users', 'u', 'user_id = link_owner'); $q->leftJoin('contacts', 'c', 'user_contact = contact_id'); if ($search != '') { $q->addWhere('(link_name LIKE \'%' . $search . '%\' OR link_description LIKE \'%' . $search . '%\')'); } if ($project_id > 0) { // Project $q->addWhere('link_project = ' . (int) $project_id); } if ($task_id > 0) { // Task $q->addWhere('link_task = ' . (int) $task_id); } if ($category_id >= 0) { // Category $q->addWhere('link_category = ' . $category_id); } // Permissions $project->setAllowedSQL($AppUI->user_id, $q, 'link_project'); $task->setAllowedSQL($AppUI->user_id, $q, 'link_task and task_project = link_project'); $q->addOrder('project_name, link_name'); return $q->loadList(); }
function setComplete($id) { global $AppUI; $task = new CTask(); if ($task->load($id)) { $q = new DBQuery(); $q->addTable('user_tasks'); $q->addQuery('user_id'); $q->addWhere('task_id = ' . $id); $q->addWhere('user_id = ' . $AppUI->user_id); $r = $q->loadResult(); if ($r != $AppUI->user_id) { $p = new CProject($task->task_project); if (!$p->project_id || $p->getManager() != $AppUI->user_id) { return 'Error'; } } $q->addTable('tasks'); $q->addUpdate('task_percent_complete', '100'); $q->addWhere('task_id = ' . $id); $q->exec(); return 'OK'; } return 'Error'; }
public static function GetOperations($collectionId, $menu = false) { global $USER; static $oCollections; static $arOp; $userGroups = $USER->GetUserGroupArray(); $key = $collectionId . '|' . implode('-', $userGroups); if (!is_array($arOp[$key])) { if (!is_array($arOp)) { $arOp = array(); } if (!is_array($oCollections)) { $res = CMedialib::GetCollectionTree(array('menu' => $menu)); $oCollections = $res['Collections']; } $userGroups = $USER->GetUserGroupArray(); $res = CMedialib::GetAccessPermissionsArray($collectionId, $oCollections); $arOp[$key] = array(); foreach ($res as $group_id => $task_id) { if (in_array($group_id, $userGroups)) { $arOp[$key] = array_merge($arOp[$key], CTask::GetOperations($task_id, true)); } } } return $arOp[$key]; }
function GetTasks() { $arTasks = Array(); $res = CTask::GetList(Array('LETTER' => 'asc'), Array('MODULE_ID' => 'fileman', 'BINDING' => 'stickers')); while($arRes = $res->Fetch()) { $name = ''; if ($arRes['SYS']) $name = GetMessage('TASK_NAME_'.strtoupper($arRes['NAME'])); if (strlen($name) == 0) $name = $arRes['NAME']; $arTasks[$arRes['ID']] = Array('title' => $name, 'letter' => $arRes['LETTER']); } return $arTasks; }
public function getProjectTaskLinksByCategory($notUsed = null, $project_id = 0, $task_id = 0, $category_id = 0, $search = '') { // load the following classes to retrieved denied records $project = new CProject(); $project->overrideDatabase($this->_query); $task = new CTask(); $task->overrideDatabase($this->_query); // SETUP FOR LINK LIST $q = $this->_getQuery(); $q->addQuery('links.*'); $q->addTable('links'); $q->leftJoin('projects', 'pr', 'project_id = link_project'); $q->leftJoin('tasks', 't', 'task_id = link_task'); if ($search != '') { $q->addWhere('(link_name LIKE \'%' . $search . '%\' OR link_description LIKE \'%' . $search . '%\')'); } if ($project_id > 0) { // Project $q->addQuery('project_name, project_color_identifier, project_status'); $q->addWhere('link_project = ' . (int) $project_id); } if ($task_id > 0) { // Task $q->addQuery('task_name, task_id'); $q->addWhere('link_task = ' . (int) $task_id); } if ($category_id >= 0) { // Category $q->addWhere('link_category = ' . $category_id); } // Permissions $q = $project->setAllowedSQL($this->_AppUI->user_id, $q, 'link_project'); $q = $task->setAllowedSQL($this->_AppUI->user_id, $q, 'link_task and task_project = link_project'); $q->addOrder('project_name, link_name'); return $q->loadList(); }
function GetTasks() { IncludeModuleLangFile($_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/fileman/admin/task_description.php"); $arTasks = array(); $res = CTask::GetList(array('LETTER' => 'asc'), array('MODULE_ID' => 'fileman', 'BINDING' => 'stickers')); while ($arRes = $res->Fetch()) { $name = ''; if ($arRes['SYS']) { $name = GetMessage('TASK_NAME_' . strtoupper($arRes['NAME'])); } if (strlen($name) == 0) { $name = $arRes['NAME']; } $arTasks[$arRes['ID']] = array('title' => $name, 'letter' => $arRes['LETTER']); } return $arTasks; }
$gantt->addBar($columnValues, ' ', 0.6, 'red'); } else { if (is_array($projects)) { //pull all tasks into an array keyed by the project id, and get the tasks in hierarchy if ($showAllGantt) { // insert tasks into Gantt Chart // select for tasks for each project // pull tasks $q = new w2p_Database_Query(); $q->addTable('tasks', 't'); $q->addQuery('t.task_id, task_parent, task_name, task_start_date, task_end_date, task_duration, task_duration_type, task_priority, task_percent_complete, task_order, task_project, task_milestone, project_id, project_name, task_dynamic'); $q->addJoin('projects', 'p', 'project_id = t.task_project'); $q->addOrder('project_id, task_start_date'); $q->addWhere('project_original_parent = ' . (int) $original_project_id); //$tasks = $q->loadList(); $task = new CTask(); $task->setAllowedSQL($AppUI->user_id, $q); $proTasks = $q->loadHashList('task_id'); $orrarr[] = array('task_id' => 0, 'order_up' => 0, 'order' => ''); $end_max = '0000-00-00 00:00:00'; $start_min = date('Y-m-d H:i:s'); //pull the tasks into an array foreach ($proTasks as $rec) { if ($rec['task_start_date'] == '0000-00-00 00:00:00') { $rec['task_start_date'] = date('Y-m-d H:i:s'); } $tsd = new w2p_Utilities_Date($rec['task_start_date']); if ($tsd->before(new w2p_Utilities_Date($start_min))) { $start_min = $rec['task_start_date']; } // calculate or set blank task_end_date if unset
$q->addQuery('t.*'); $q->addJoin('projects', '', 'projects.project_id = task_project', 'inner'); $q->addJoin('project_departments', '', 'project_departments.project_id = projects.project_id'); $q->addJoin('departments', '', 'department_id = dept_id'); $q->addWhere('project_active = 1'); if (($template_status = w2PgetConfig('template_projects_status_id')) != '') { $q->addWhere('project_status <> ' . (int) $template_status); } if ($use_period) { $q->addWhere('( (task_start_date >= ' . $ss . ' AND task_start_date <= ' . $se . ') OR ' . '(task_end_date <= ' . $se . ' AND task_end_date >= ' . $ss . ') )'); } if ($project_id != 0) { $q->addWhere('task_project=' . $project_id); } $proj = new CProject(); $obj = new CTask(); $allowedProjects = $proj->getAllowedSQL($AppUI->user_id, 'task_project'); $allowedTasks = $obj->getAllowedSQL($AppUI->user_id); if (count($allowedProjects)) { $q->addWhere(implode(' AND ', $allowedProjects)); } if (count($allowedTasks)) { $q->addWhere(implode(' AND ', $allowedTasks)); } $q->addOrder('task_end_date'); $task_list_hash = $q->loadHashList('task_id'); $q->clear(); $task_list = array(); $task_assigned_users = array(); $i = 0; foreach ($task_list_hash as $task_id => $task_data) {
if ($rcode == "ER") { $errorMessage .= substr($responseBody, 2) . "<br />"; } elseif ($rcode != "OK") { $errorMessage .= GetMessage("SPTEN_SCRM_ERR_ANSWER") . "<br />"; } else { $crmUrl4Import = trim(substr($responseBody, 2)); } } } if (empty($errorMessage)) { if ($createNewSaleUser) { $APPLICATION->SetGroupRight("sale", $groupId, "W", false); //$APPLICATION->SetGroupRight("catalog", $groupId, "R", false); CGroup::SetModulePermission($groupId, "catalog", CTask::GetIdByLetter("R", "catalog")); //$APPLICATION->SetGroupRight("main", $groupId, "R", false); CGroup::SetModulePermission($groupId, "main", CTask::GetIdByLetter("R", "main")); $opt = COption::GetOptionString("sale", "1C_SALE_GROUP_PERMISSIONS", ""); $opt .= ($opt != "" ? "," : "") . $groupId; COption::SetOptionString("sale", "1C_SALE_GROUP_PERMISSIONS", $opt); function GetAccessArrTmp() { $PERM = array(); @(include $_SERVER["DOCUMENT_ROOT"] . "/bitrix/.access.php"); return $PERM; } $arFPermsTmp = GetAccessArrTmp(); $arFPerms = array_key_exists("admin", $arFPermsTmp) ? $arFPermsTmp["admin"] : array(); $arFPerms[$groupId . ""] = "R"; $APPLICATION->SetFileAccessPermission(array(SITE_ID, "/bitrix/admin"), $arFPerms); } LocalRedirect($APPLICATION->GetCurPage() . "?lang=" . LANGUAGE_ID . "&success=Y&crm_imp_url=" . urlencode(($crmUrlScheme == 'ssl://' ? "https" : "http") . "://" . $crmUrlHost . ":" . $crmUrlPort . $crmUrl4Import) . "&crm_url=" . urlencode(($crmUrlScheme == 'ssl://' ? "https" : "http") . "://" . $crmUrlHost . ":" . $crmUrlPort));
// prepare a list of tasks to process $htasks_ar = array(); if (isset($htasks)) { $tarr = explode(',', $htasks); foreach ($tarr as $tid) { if (intval($tid) > 0) { $htasks_ar[] = $tid; } } } $sizeof = sizeof($htasks_ar); for ($i = 0; $i <= $sizeof; $i++) { $_POST['task_id'] = $htasks_ar[$i]; // verify that task_id is not NULL if ($_POST['task_id'] > 0) { $obj = new CTask(); if (!$obj->bind($_POST)) { $AppUI->setMsg($obj->getError(), UI_MSG_ERROR); $AppUI->redirect(); } if ($rm && $del) { $overAssignment = $obj->updateAssigned($hassign, $hperc_assign_ar, true, true); if ($overAssignment) { $AppUI->setMsg('Some Users could not be unassigned from Task', UI_MSG_ERROR); } else { // Don't do anything because we might have other tasks to change // $AppUI->setMsg('User(s) unassigned from Task', UI_MSG_OK); // $AppUI->redirect(); } } else { if ($rm || $del) {
/** * Sub-function to collect tasks within a period * * @param Date the starting date of the period * @param Date the ending date of the period * @param array by-ref an array of links to append new items to * @param int the length to truncate entries by * @param int the company id to filter by * @author Andrew Eddie <*****@*****.**> */ function getTaskLinks($startPeriod, $endPeriod, &$links, $strMaxLen, $company_id = 0) { global $a, $AppUI, $dPconfig; $tasks = CTask::getTasksForPeriod($startPeriod, $endPeriod, $company_id, $AppUI->user_id, true); $durnTypes = dPgetSysVal('TaskDurationType'); $link = array(); $sid = 3600 * 24; // assemble the links for the tasks foreach ($tasks as $row) { // the link $link['href'] = "?m=tasks&a=view&task_id=" . $row['task_id']; $link['alt'] = $row['project_name'] . ":\n" . $row['task_name']; // the link text if (strlen($row['task_name']) > $strMaxLen) { $row['task_name'] = substr($row['task_name'], 0, $strMaxLen) . '...'; } $link['text'] = '<span style="color:' . bestColor($row['color']) . ';background-color:#' . $row['color'] . '">' . $row['task_name'] . '</span>'; // determine which day(s) to display the task $start = new CDate($row['task_start_date']); $end = $row['task_end_date'] ? new CDate($row['task_end_date']) : null; $durn = $row['task_duration']; $durnType = $row['task_duration_type']; if (($start->after($startPeriod) || $start->equals($startPeriod)) && ($start->before($endPeriod) || $start->equals($endPeriod))) { $temp = $link; $temp['alt'] = "START [" . $row['task_duration'] . ' ' . $AppUI->_($durnTypes[$row['task_duration_type']]) . "]\n" . $link['alt']; if ($a != 'day_view') { $temp['text'] = dPshowImage(dPfindImage('block-start-16.png')) . $temp['text']; } $links[$start->format(FMT_TIMESTAMP_DATE)][] = $temp; } if ($end && $end->after($startPeriod) && $end->before($endPeriod) && $start->before($end)) { $temp = $link; $temp['alt'] = "FINISH\n" . $link['alt']; if ($a != 'day_view') { $temp['text'] .= dPshowImage(dPfindImage('block-end-16.png')); } $links[$end->format(FMT_TIMESTAMP_DATE)][] = $temp; } // convert duration to days if ($durnType < 24.0) { if ($durn > $dPconfig['daily_working_hours']) { $durn /= $dPconfig['daily_working_hours']; } else { $durn = 0.0; } } else { $durn *= $durnType / 24.0; } // fill in between start and finish based on duration // notes: // start date is not in a future month, must be this or past month // start date is counted as one days work // business days are not taken into account $target = $start; $target->addSeconds($durn * $sid); if (Date::compare($target, $startPeriod) < 0) { continue; } if (Date::compare($start, $startPeriod) > 0) { $temp = $start; $temp->addSeconds($sid); } else { $temp = $startPeriod; } // Optimised for speed, AJD. while (Date::compare($endPeriod, $temp) > 0 && Date::compare($target, $temp) > 0 && ($end == null || $temp->before($end))) { $links[$temp->format(FMT_TIMESTAMP_DATE)][] = $link; $temp->addSeconds($sid); } } }
$q->addWhere('task_parent = ' . (int) $row['task_id']); $q->addWhere('task_id <> task_parent'); $row['children'] = $q->loadResult(); $row['style'] = taskstyle_pd($row); $i = count($projects[$row['task_project']]['tasks']) + 1; $row['task_number'] = $i; $row['node_id'] = 'node_' . $i . '-' . $row['task_id']; if (strpos($row['task_duration'], '.') && $row['task_duration_type'] == 1) { $row['task_duration'] = floor($row['task_duration']) . ':' . round(60 * ($row['task_duration'] - floor($row['task_duration']))); } //pull the final task row into array $projects[$row['task_project']]['tasks'][] = $row; } $showEditCheckbox = isset($canEditTasks) && $canEditTasks || $perms->checkModule('admin', 'view'); $durnTypes = w2PgetSysVal('TaskDurationType'); $tempoTask = new CTask(); $userAlloc = $tempoTask->getAllocation('user_id'); ?> <table width="100%" border="0" cellpadding="1" cellspacing="3" class="prjprint"> <tr class="prjprint"> <th width="50%"><?php echo $AppUI->_('Task Name'); ?> </th> <th width="50" nowrap="nowrap"><?php echo $AppUI->_('Work'); ?> </th> <th nowrap="nowrap"><?php echo $AppUI->_('Start'); ?>
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } global $DBType; require_once $_SERVER['DOCUMENT_ROOT'] . "/bitrix/modules/main/classes/" . strtolower($DBType) . "/favorites.php"; __IncludeLang(GetLangFileName(dirname(__FILE__) . "/lang/", "/" . basename(__FILE__))); //Change site name $obSite = new CSite(); $obSite->Update("s1", array("NAME" => COption::GetOptionString("main", "site_name", GetMessage("DEFAULT_SITE_NAME")))); //Edit profile task $editProfileTask = false; $dbResult = CTask::GetList(array(), array("NAME" => "main_change_profile")); if ($arTask = $dbResult->Fetch()) { $editProfileTask = $arTask["ID"]; } //admin security policy $z = CGroup::GetByID(1); if ($res = $z->Fetch()) { if ($res["SECURITY_POLICY"] == "") { $group = new CGroup(); $arGroupPolicy = array("SESSION_TIMEOUT" => 15, "SESSION_IP_MASK" => "255.255.255.255", "MAX_STORE_NUM" => 1, "STORE_IP_MASK" => "255.255.255.255", "STORE_TIMEOUT" => 60 * 24 * 3, "CHECKWORD_TIMEOUT" => 60, "PASSWORD_LENGTH" => 10, "PASSWORD_UPPERCASE" => "Y", "PASSWORD_LOWERCASE" => "Y", "PASSWORD_DIGITS" => "Y", "PASSWORD_PUNCTUATION" => "Y", "LOGIN_ATTEMPTS" => 3); $arFields = array("SECURITY_POLICY" => serialize($arGroupPolicy)); $group->Update(1, $arFields); } } //Registered users group $dbResult = CGroup::GetList($by, $order, array("STRING_ID" => "REGISTERED_USERS")); if ($dbResult->Fetch()) { return;
$userGroupID = ""; $dbGroup = CGroup::GetList($by = "", $order = "", array("STRING_ID" => "content_editor")); if ($arGroup = $dbGroup->Fetch()) { $userGroupID = $arGroup["ID"]; } else { $group = new CGroup(); $arFields = array("ACTIVE" => "Y", "C_SORT" => 300, "NAME" => GetMessage("SALE_WIZARD_CONTENT_EDITOR"), "DESCRIPTION" => GetMessage("SALE_WIZARD_CONTENT_EDITOR_DESCR"), "USER_ID" => array(), "STRING_ID" => "content_editor"); $userGroupID = $group->Add($arFields); $DB->Query("INSERT INTO b_sticker_group_task(GROUP_ID, TASK_ID)\tSELECT " . intVal($userGroupID) . ", ID FROM b_task WHERE NAME='stickers_edit' AND MODULE_ID='fileman'", false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__); } if (IntVal($userGroupID) > 0) { WizardServices::SetFilePermission(array($siteID, "/bitrix/admin"), array($userGroupID => "R")); $rsTasks = CTask::GetList(array(), array("MODULE_ID" => "main", "SYS" => "Y", "BINDIG" => "module", "LETTER" => "P")); if ($arTask = $rsTasks->Fetch()) { CGroup::SetModulePermission($userGroupID, $arTask["MODULE_ID"], $arTask["ID"]); } $rsTasks = CTask::GetList(array(), array("MODULE_ID" => "fileman", "SYS" => "Y", "BINDIG" => "module", "LETTER" => "F")); if ($arTask = $rsTasks->Fetch()) { CGroup::SetModulePermission($userGroupID, $arTask["MODULE_ID"], $arTask["ID"]); } $SiteDir = ""; if (WIZARD_SITE_ID != "s1") { $SiteDir = "/site_" . WIZARD_SITE_ID; } WizardServices::SetFilePermission(array($siteID, $SiteDir . "/index.php"), array($userGroupID => "W")); WizardServices::SetFilePermission(array($siteID, $SiteDir . "/about/"), array($userGroupID => "W")); WizardServices::SetFilePermission(array($siteID, $SiteDir . "/news/"), array($userGroupID => "W")); WizardServices::SetFilePermission(array($siteID, $SiteDir . "/catalog/"), array($userGroupID => "W")); WizardServices::SetFilePermission(array($siteID, $SiteDir . "/personal/"), array($userGroupID => "W")); } COption::SetOptionString("eshop", "wizard_installed", "Y", false, WIZARD_SITE_ID);
if ($user_id) { $q->addWhere("t.task_owner = '{$user_id}'"); } if ($project_id != 0) { $q->addWhere("t.task_project='{$project_id}'"); } $proj =& new CProject(); $proj->setAllowedSQL($AppUI->user_id, $q); $obj =& new CTask(); $obj->setAllowedSQL($AppUI->user_id, $q); $task_list_hash = $q->loadHashList('task_id'); $q->clear(); $task_list = array(); $fetched_projects = array(); foreach ($task_list_hash as $task_id => $task_data) { $task = new CTask(); $task->bind($task_data); $task_list[] = $task; $fetched_projects[$task->task_project] = $task_data["project_name"]; } $user_usage = array(); $task_dates = array(); $actual_date = $start_date; $days_header = ""; // we will save days title here $user_tasks_counted_in = array(); $user_names = array(); if (count($task_list) == 0) { echo "<p>" . $AppUI->_('No data available') . "</p>"; } else { foreach ($task_list as $task) {
</label> </td> <td align="left" nowrap="nowrap"> <input class="button" type="submit" name="do_report" value="<?php echo $AppUI->_('submit'); ?> " /> </td> </tr> </table> </form> <?php echo $AppUI->_('P') . ' = ' . $AppUI->_('User specific Task Priority'); if ($do_report) { // get Users with all Allocation info (e.g. their freeCapacity) $tempoTask = new CTask(); $userAlloc = $tempoTask->getAllocation("user_id"); // Let's figure out which users we have $sql = new DBQuery(); $sql->addTable('users'); $sql->addQuery('user_id, user_username'); if ($log_userfilter != 0) { $sql->addWhere('user_id = ' . $log_userfilter); } $sql->addOrder('user_username'); $user_list = $sql->loadHashList('user_id'); $sql->clear(); $ss = $start_date->format(FMT_DATETIME_MYSQL); $se = $end_date->format(FMT_DATETIME_MYSQL); $sql->addTable('tasks', 't'); $sql->innerJoin('projects', 'p', 'p.project_id = t.task_project');
$extra = array('where' => 'project_active = 1'); $project = new CProject(); $projects = $project->getAllowedRecords($AppUI->user_id, 'projects.project_id,project_name', 'project_name', null, $extra, 'projects'); $q = new DBQuery(); $q->addTable('projects'); $q->addQuery('projects.project_id, company_name'); $q->addJoin('companies', 'co', 'co.company_id = project_company'); $idx_companies = $q->loadHashList(); $q->clear(); foreach ($projects as $prj_id => $prj_name) { $projects[$prj_id] = $idx_companies[$prj_id] . ': ' . $prj_name; } asort($projects); $projects = arrayMerge(array('0' => $AppUI->_('(None)', UI_OUTPUT_RAW)), $projects); $extra = array(); $task = new CTask(); $tasks = $task->getAllowedRecords($AppUI->user_id, 'task_id,task_name', 'task_name', null, $extra); $tasks = arrayMerge(array('0' => $AppUI->_('(None)', UI_OUTPUT_RAW)), $tasks); if (!$project_id) { //$AppUI->redirect('m=projects&pd=1'); // setup the title block $ttl = 'ProjectDesigner'; $titleBlock = new CTitleBlock($ttl, 'projectdesigner.png', $m, $m . '.' . $a); $titleBlock->addCrumb('?m=projects', 'projects list'); $titleBlock->addCell(); if ($canAddProject) { $titleBlock->addCell('<input type="submit" class="button" value="' . $AppUI->_('new project') . '">', '', '<form action="?m=projects&a=addedit" method="post" accept-charset="utf-8">', '</form>'); } $titleBlock->show(); ?> <script language="javascript">
/** * Test updating hours worked for a task */ public function testUpdateHoursWorked() { CTask::updateHoursWorked(1, 25); $xml_file_dataset = $this->createXMLDataSet($this->getDataSetPath() . 'tasksTestUpdateHoursWorked.xml'); $xml_db_dataset = $this->getConnection()->createDataSet(); $this->assertTablesEqual($xml_file_dataset->getTable('tasks'), $xml_db_dataset->getTable('tasks')); }
$obj = new CCompany(); $allowed_companies_ary = $obj->getAllowedRecords($AppUI->user_id, 'company_id,company_name', 'company_name'); $allowed_companies = implode(",", array_keys($allowed_companies_ary)); if (!isset($task_id)) { $task_id = dPgetParam($_REQUEST, 'task_id', 0); } global $xpg_min, $xpg_pagesize; $xpg_pagesize = 30; $xpg_min = $xpg_pagesize * ($page - 1); // This is where we start our record set from // load the following classes to retrieved denied records include_once $AppUI->getModuleClass('projects'); include_once $AppUI->getModuleClass('tasks'); $project = new CProject(); $deny1 = $project->getDeniedRecords($AppUI->user_id); $task = new CTask(); $deny2 = $task->getDeniedRecords($AppUI->user_id); global $file_types; $file_types = dPgetSysVal("FileType"); $folder = $folder ? $folder : 0; // SQL text for count the total recs from the selected option $q = new DBQuery(); $q->addTable('files'); $q->addQuery('count(files.file_id)'); $q->addJoin('projects', 'p', 'p.project_id = file_project'); $q->addJoin('users', 'u', 'u.user_id = file_owner'); $q->addJoin('tasks', 't', 't.task_id = file_task'); $q->addJoin('file_folders', 'ff', 'ff.file_folder_id = file_folder'); $q->addWhere('file_folder = ' . $folder); if (count($deny1) > 0) { $q->addWhere('file_project NOT IN (' . implode(',', $deny1) . ')');
$cap = ''; } if ($showLabels) { $caption .= $AppUI->_($projectStatus[$p['project_status']]) . ', '; $caption .= $p['project_active'] != 0 ? $AppUI->_('active') : $AppUI->_('archived'); } $enddate = new w2p_Utilities_Date($end); $startdate = new w2p_Utilities_Date($start); $actual_end = intval($p['project_actual_end_date']) ? $p['project_actual_end_date'] : $end; $columnValues = array('project_name' => $pname, 'start_date' => $start, 'end_date' => $end, 'actual_end' => $actual_end); $gantt->addBar($columnValues, $caption, 0.6, $p['project_color_identifier'], $p['project_active'], $progress, $p['project_id']); // If showAllGant checkbox is checked if ($showAllGantt) { // insert tasks into Gantt Chart // select for tasks for each project $task = new CTask(); $orderBy = $sortTasksByName ? 'task_name' : 'task_end_date ASC'; $tasks = $task->getAllowedTaskList($AppUI, $p['project_id'], $orderBy); $bestColor = bestColor('#ffffff', '#' . $p['project_color_identifier'], '#000000'); foreach ($tasks as $t) { $name = $t['task_name']; $name = mb_strlen($name) > 34 ? mb_substr($name, 0, 30) . '...' : $name; //Check if start date exists, if not try giving it the end date. //If the end date does not exist then set it for today. //This avoids jpgraphs internal errors that render the gantt completely useless if ($t['task_start_date'] == '0000-00-00 00:00:00') { if ($t['task_end_date'] == '0000-00-00 00:00:00') { $todaydate = new w2p_Utilities_Date(); $t['task_start_date'] = $todaydate->format(FMT_TIMESTAMP_DATE); } else { $t['task_start_date'] = $t['task_end_date'];
//$upd_task->updateAssigned($bulk_task_assign,array($bulk_task_assign=>$bulk_task_assign_perc),false,false); if ($upd_task->task_project && $upd_task->task_id && $upd_task->task_notify) { $upd_task->notify(); } } //Action: Unassign User if (isset($_POST['bulk_task_unassign']) && $bulk_task_unassign != '') { $upd_task = new CTask(); $upd_task->load($key); if ($upd_task->task_id) { $upd_task->removeAssigned($bulk_task_unassign); } } // Action: Allow user to add task logs for others if (isset($_POST['bulk_task_allow_other_user_tasklogs']) && $bulk_task_allow_other_user_tasklogs != '') { $upd_task = new CTask(); $upd_task->load($key); if ($upd_task->task_id) { $upd_task->task_allow_other_user_tasklogs = $bulk_task_allow_other_user_tasklogs; $result = $upd_task->store($AppUI); if (is_array($result)) { break; } } } //Action: Other Actions if (isset($_POST['bulk_task_other']) && $bulk_task_other != '') { if ($upd_task->task_id) { //Option 1 - Mark as finished if ($bulk_task_other == '1') { $upd_task->task_percent_complete = 100;
} else { $cols--; } if ($showEditCheckbox) { echo '<th width="1"> </th>'; } else { $cols--; } ?> </tr> <?php reset($projects); if ($w2Pconfig['direct_edit_assignment']) { // get Users with all Allocation info (e.g. their freeCapacity) // but do it only when direct_edit_assignment is on and only once. $tempoTask = new CTask(); $userAlloc = $tempoTask->getAllocation('user_id', null, true); } foreach ($projects as $k => $p) { $tnums = isset($p['tasks']) ? count($p['tasks']) : 0; if ($tnums > 0 || $project_id == $p['project_id']) { //echo '<pre>'; print_r($p); echo '</pre>'; if (!$min_view) { // not minimal view $open_link = w2PtoolTip($m, 'Click to Expand/Collapse the Tasks for this Project.') . '<a href="javascript: void(0);"><img onclick="expand_collapse(\'project_' . $p['project_id'] . '_\', \'tblProjects\',\'collapse\',0,2);" id="project_' . $p['project_id'] . '__collapse" src="' . w2PfindImage('up22.png', $m) . '" border="0" width="22" height="22" align="center" ' . (!$expanded ? 'style="display:none"' : '') . ' alt="" /><img onclick="expand_collapse(\'project_' . $p['project_id'] . '_\', \'tblProjects\',\'expand\',0,2);" id="project_' . $p['project_id'] . '__expand" src="' . w2PfindImage('down22.png', $m) . '" border="0" width="22" height="22" align="center" ' . ($expanded ? 'style="display:none"' : '') . ' alt="" /></a>' . w2PendTip(); ?> <tr> <td> <form name="assFrm<?php echo $p['project_id']; ?>
/** * The original method didn't return anything.. * * @todo Remove for v4.0 - caseydk 06 March 2013 * @deprecated */ function get_dependencies_pd($task_id) { trigger_error("get_dependencies_pd() has been deprecated in v3.0 and will be removed in v4.0. Use CTask->getDependencyList instead.", E_USER_NOTICE); $task = new CTask(); return $task->getDependencyList($task_id); }
$current_uriArray = parse_url($_SERVER['REQUEST_URI']); $current_uri = $current_uriArray['query']; $tab = !$company_id && !$project_id && !$task_id || $m == 'files' ? $currentTabId : 0; $page = w2PgetParam($_GET, 'page', 1); if (!isset($project_id)) { $project_id = w2PgetParam($_REQUEST, 'project_id', 0); } if (!isset($showProject)) { $showProject = true; } $xpg_pagesize = w2PgetConfig('page_size', 50); $xpg_min = $xpg_pagesize * ($page - 1); // This is where we start our record set from // load the following classes to retrieved denied records $project = new CProject(); $task = new CTask(); $df = $AppUI->getPref('SHDATEFORMAT'); $tf = $AppUI->getPref('TIMEFORMAT'); if (($company_id || $project_id || $task_id) && !($m == 'files')) { $catsql = false; } elseif ($tabbed) { if ($tab <= 0) { $catsql = false; } else { $catsql = 'file_category = ' . ($tab - 1); } } else { if ($tab < 0) { $catsql = false; } else { $catsql = 'file_category = ' . $tab;
function getDeepChildren() { $q = new DBQuery(); $q->addTable('tasks'); $q->addQuery('task_id'); $q->addWhere("task_id <> '" . $this->task_id . "' AND task_parent = '" . $this->task_id . "'"); $sql = $q->prepare(); $q->clear(); $children = db_loadColumn($sql); if ($children) { $deep_children = array(); $tempTask = new CTask(); foreach ($children as $child) { $tempTask->peek($child); $deep_children = array_merge($deep_children, $tempTask->getDeepChildren()); } return array_merge($children, $deep_children); } return array(); }
public function getAllTasksForPeriod($start_date, $end_date, $company_id = 0, $user_id = null) { global $AppUI; $q = new w2p_Database_Query(); // convert to default db time stamp $db_start = $start_date->format(FMT_DATETIME_MYSQL); $db_end = $end_date->format(FMT_DATETIME_MYSQL); // Allow for possible passing of user_id 0 to stop user filtering if (!isset($user_id)) { $user_id = $AppUI->user_id; } // check permissions on projects $proj = new CProject(); $task_filter_where = $proj->getAllowedSQL($AppUI->user_id, 't.task_project'); // exclude read denied projects $deny = $proj->getDeniedRecords($AppUI->user_id); // check permissions on tasks $obj = new CTask(); $allow = $obj->getAllowedSQL($AppUI->user_id, 't.task_id'); $q->addTable('tasks', 't'); if ($user_id) { $q->innerJoin('user_tasks', 'ut', 't.task_id=ut.task_id'); } $q->innerJoin('projects', 'projects', 't.task_project = projects.project_id'); $q->innerJoin('companies', 'companies', 'projects.project_company = companies.company_id'); $q->leftJoin('project_departments', '', 'projects.project_id = project_departments.project_id'); $q->leftJoin('departments', '', 'departments.dept_id = project_departments.department_id'); $q->addQuery('DISTINCT t.task_id, t.task_name, t.task_start_date, t.task_end_date, t.task_percent_complete, t.task_duration' . ', t.task_duration_type, projects.project_color_identifier AS color, projects.project_name, t.task_milestone, task_description, task_type, company_name, task_access, task_owner'); $q->addWhere('task_status > -1' . ' AND (task_start_date <= \'' . $db_end . '\' AND t.task_percent_complete<100 OR task_end_date = \'0000-00-00 00:00:00\' OR task_end_date = NULL )'); $q->addWhere('project_active = 1'); if (($template_status = w2PgetConfig('template_projects_status_id')) != '') { $q->addWhere('project_status <> ' . $template_status); } if ($user_id) { $q->addWhere('ut.user_id = ' . (int) $user_id); } if ($company_id) { $q->addWhere('projects.project_company = ' . (int) $company_id); } if (count($task_filter_where) > 0) { $q->addWhere('(' . implode(' AND ', $task_filter_where) . ')'); } if (count($deny) > 0) { $q->addWhere('(t.task_project NOT IN (' . implode(', ', $deny) . '))'); } if (count($allow) > 0) { $q->addWhere('(' . implode(' AND ', $allow) . ')'); } $q->addOrder('t.task_start_date'); // assemble query $tasks = $q->loadList(-1, 'task_id'); // check tasks access $result = array(); foreach ($tasks as $key => $row) { $obj->load($row['task_id']); $canAccess = $obj->canAccess(); if (!$canAccess) { continue; } $result[$key] = $row; } // execute and return return $result; }
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } if (WIZARD_IS_RERUN) { return; } if (!CModule::IncludeModule("fileman")) { return; } $arAccessRights = array(WIZARD_PORTAL_ADMINISTRATION_GROUP => 'F', WIZARD_PERSONNEL_DEPARTMENT_GROUP => 'F'); $arTaskIDs = array(); $dbRes = CTask::GetList(array(), array('MODULE_ID' => 'fileman', 'SYS' => 'Y', 'LETTER' => implode('|', $arAccessRights), 'BINDING' => 'module')); while ($arRes = $dbRes->Fetch()) { $arTaskIDs[$arRes['LETTER']] = $arRes['ID']; } $arTasksForModule = array(); foreach ($arAccessRights as $group => $letter) { $APPLICATION->SetGroupRight('fileman', $group, $letter); $arTasksForModule[$group] = array('ID' => $arTaskIDs[$letter]); } CGroup::SetTasksForModule('fileman', $arTasksForModule);
function CanUserOperateDocumentType($operation, $userId, $documentType, $parameters = array()) { $documentType = trim($documentType); if (strlen($documentType) <= 0) { return false; } $parameters["IBlockId"] = intval(substr($documentType, strlen("iblock_"))); $parameters['sectionId'] = !empty($parameters['sectionId']) ? (int) $parameters['sectionId'] : 0; if (!array_key_exists("IBlockRightsMode", $parameters)) { $parameters["IBlockRightsMode"] = CIBlock::getArrayByID($parameters["IBlockId"], "RIGHTS_MODE"); } if ($parameters["IBlockRightsMode"] === "E") { if ($operation === CBPCanUserOperateOperation::CreateWorkflow) { return CIBlockRights::userHasRightTo($parameters["IBlockId"], $parameters["IBlockId"], "iblock_rights_edit"); } elseif ($operation === CBPCanUserOperateOperation::WriteDocument) { return CIBlockSectionRights::userHasRightTo($parameters["IBlockId"], $parameters["sectionId"], "section_element_bind"); } elseif ($operation === CBPCanUserOperateOperation::ViewWorkflow || $operation === CBPCanUserOperateOperation::StartWorkflow) { if (!array_key_exists("WorkflowId", $parameters)) { return false; } if ($operation === CBPCanUserOperateOperation::ViewWorkflow) { return CIBlockRights::userHasRightTo($parameters["IBlockId"], 0, "element_read"); } if ($operation === CBPCanUserOperateOperation::StartWorkflow) { return CIBlockSectionRights::userHasRightTo($parameters["IBlockId"], $parameters['sectionId'], "section_element_bind"); } $userId = intval($userId); if (!array_key_exists("AllUserGroups", $parameters)) { if (!array_key_exists("UserGroups", $parameters)) { $parameters["UserGroups"] = CUser::getUserGroup($userId); } $parameters["AllUserGroups"] = $parameters["UserGroups"]; $parameters["AllUserGroups"][] = "Author"; } if (!array_key_exists("DocumentStates", $parameters)) { if ($operation === CBPCanUserOperateOperation::StartWorkflow) { $parameters["DocumentStates"] = CBPWorkflowTemplateLoader::getDocumentTypeStates(array("lists", get_called_class(), "iblock_" . $parameters["IBlockId"])); } else { $parameters["DocumentStates"] = CBPDocument::getDocumentStates(array("lists", get_called_class(), "iblock_" . $parameters["IBlockId"]), null); } } if (array_key_exists($parameters["WorkflowId"], $parameters["DocumentStates"])) { $parameters["DocumentStates"] = array($parameters["WorkflowId"] => $parameters["DocumentStates"][$parameters["WorkflowId"]]); } else { return false; } $allowableOperations = CBPDocument::getAllowableOperations($userId, $parameters["AllUserGroups"], $parameters["DocumentStates"], true); if (!is_array($allowableOperations)) { return false; } if ($operation === CBPCanUserOperateOperation::ViewWorkflow && in_array("read", $allowableOperations) || $operation === CBPCanUserOperateOperation::StartWorkflow && in_array("write", $allowableOperations)) { return true; } $chop = $operation === CBPCanUserOperateOperation::ViewWorkflow ? "element_read" : "section_element_bind"; $tasks = self::getRightsTasks(); foreach ($allowableOperations as $op) { if (isset($tasks[$op])) { $op = $tasks[$op]['ID']; } $ar = CTask::getOperations($op, true); if (in_array($chop, $ar)) { return true; } } } return false; } if (!array_key_exists("IBlockPermission", $parameters)) { if (CModule::includeModule('lists')) { $parameters["IBlockPermission"] = CLists::getIBlockPermission($parameters["IBlockId"], $userId); } else { $parameters["IBlockPermission"] = CIBlock::getPermission($parameters["IBlockId"], $userId); } } if ($parameters["IBlockPermission"] <= "R") { return false; } elseif ($parameters["IBlockPermission"] >= "W") { return true; } $userId = intval($userId); if (!array_key_exists("AllUserGroups", $parameters)) { if (!array_key_exists("UserGroups", $parameters)) { $parameters["UserGroups"] = CUser::getUserGroup($userId); } $parameters["AllUserGroups"] = $parameters["UserGroups"]; $parameters["AllUserGroups"][] = "Author"; } if (!array_key_exists("DocumentStates", $parameters)) { $parameters["DocumentStates"] = CBPDocument::getDocumentStates(array("lists", get_called_class(), "iblock_" . $parameters["IBlockId"]), null); } if (array_key_exists("WorkflowId", $parameters)) { if (array_key_exists($parameters["WorkflowId"], $parameters["DocumentStates"])) { $parameters["DocumentStates"] = array($parameters["WorkflowId"] => $parameters["DocumentStates"][$parameters["WorkflowId"]]); } else { return false; } } $allowableOperations = CBPDocument::getAllowableOperations($userId, $parameters["AllUserGroups"], $parameters["DocumentStates"]); if (!is_array($allowableOperations)) { return false; } $r = false; switch ($operation) { case CBPCanUserOperateOperation::ViewWorkflow: $r = in_array("read", $allowableOperations); break; case CBPCanUserOperateOperation::StartWorkflow: $r = in_array("write", $allowableOperations); break; case CBPCanUserOperateOperation::CreateWorkflow: $r = in_array("write", $allowableOperations); break; case CBPCanUserOperateOperation::WriteDocument: $r = in_array("write", $allowableOperations); break; case CBPCanUserOperateOperation::ReadDocument: $r = false; break; default: $r = false; } return $r; }
public function getDeepChildren() { $children = $this->getChildren(); if ($children) { $deep_children = array(); $tempTask = new CTask(); foreach ($children as $child) { $tempTask->load($child); $deep_children = array_merge($deep_children, $tempTask->getDeepChildren()); } return array_merge($children, $deep_children); } return array(); }