当前位置: 首页>>代码示例>>PHP>>正文


PHP ProjectTasks::instance方法代码示例

本文整理汇总了PHP中ProjectTasks::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP ProjectTasks::instance方法的具体用法?PHP ProjectTasks::instance怎么用?PHP ProjectTasks::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ProjectTasks的用法示例。


在下文中一共展示了ProjectTasks::instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: gen_id

<?php
$genid = gen_id();
$limit = 20;
$total = $limit;
$page = 10;

$task_assignment_conditions = "";
if (!SystemPermissions::userHasSystemPermission(logged_user(), 'can_see_assigned_to_other_tasks')) {
	$task_assignment_conditions = " AND assigned_to_contact_id = ".logged_user()->getId();
}

$tasks_result = ProjectTasks::instance()->listing(array(
	"order" => "completed_on",
	"order_dir" => "DESC",
	"extra_conditions" => " AND is_template = 0 AND completed_by_id > 0 $task_assignment_conditions",
	"limit" => $limit + 1,
));

$tasks = $tasks_result->objects;

$active_members = array();
$context = active_context();
foreach ($context as $selection) {
	if ($selection instanceof Member) $active_members[] = $selection;
}
if (count($active_members) > 0) {
	$mnames = array();
	$allowed_contact_ids = array();
	foreach ($active_members as $member) {
		$mnames[] = clean($member->getName());
	}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:31,代码来源:index.php

示例2: new_list_tasks


//.........这里部分代码省略.........
             $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `due_date` = '{$now}'";
             break;
         case 13:
             // Today + Overdue tasks
             $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `due_date` <= '{$now}'";
             break;
         case 14:
             // Today + Overdue tasks
             $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `due_date` <= '{$now}'";
             break;
         case 20:
             // Actives task by current user
             $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `start_date` <= '{$now}' AND `assigned_to_contact_id` = " . logged_user()->getId();
             break;
         case 21:
             // Subscribed tasks by current user
             $res20 = DB::execute("SELECT object_id FROM " . TABLE_PREFIX . "object_subscriptions WHERE `contact_id` = " . logged_user()->getId());
             $subs_rows = $res20->fetchAll($res20);
             foreach ($subs_rows as $row) {
                 $subs[] = $row['object_id'];
             }
             unset($res20, $subs_rows, $row);
             $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `id` IN(" . implode(',', $subs) . ")";
             break;
         case 2:
             // All tasks
             break;
         default:
             throw new Exception('Task status "' . $status . '" not recognised');
     }
     $conditions = "AND {$template_condition} {$task_filter_condition} {$task_status_condition}";
     //Now get the tasks
     //$tasks = ProjectTasks::getContentObjects(active_context(), ObjectTypes::findById(ProjectTasks::instance()->getObjectTypeId()), null, null, $conditions,null)->objects;
     $tasks = ProjectTasks::instance()->listing(array("extra_conditions" => $conditions, "start" => 0, "limit" => 501, "count_results" => false))->objects;
     $pendingstr = $status == 0 ? " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " " : "";
     $milestone_conditions = " AND `is_template` = false " . $pendingstr;
     //Find all internal milestones for these tasks
     //$internalMilestones = ProjectMilestones::getContentObjects(active_context(), ObjectTypes::findById(ProjectMilestones::instance()->getObjectTypeId()), null, null, $milestone_conditions,null)->objects;
     $internalMilestones = ProjectMilestones::instance()->listing(array("extra_conditions" => $milestone_conditions))->objects;
     //Find all external milestones for these tasks, external milestones are the ones that belong to a parent member and have tasks in the current member
     $milestone_ids = array();
     if ($tasks) {
         foreach ($tasks as $task) {
             if ($task->getMilestoneId() != 0) {
                 $milestone_ids[$task->getMilestoneId()] = $task->getMilestoneId();
             }
         }
     }
     $int_milestone_ids = array();
     foreach ($internalMilestones as $milestone) {
         $int_milestone_ids[] = $milestone->getId();
     }
     $milestone_ids = array_diff($milestone_ids, $int_milestone_ids);
     if (count($milestone_ids) == 0) {
         $milestone_ids[] = 0;
     }
     $ext_milestone_conditions = " `is_template` = false " . $pendingstr . ' AND `object_id` IN (' . implode(',', $milestone_ids) . ')';
     $externalMilestones = ProjectMilestones::findAll(array('conditions' => $ext_milestone_conditions));
     // Get Users Info
     $users = allowed_users_in_context(ProjectTasks::instance()->getObjectTypeId(), active_context(), ACCESS_LEVEL_READ);
     $allUsers = Contacts::getAllUsers();
     $user_ids = array(-1);
     foreach ($users as $user) {
         $user_ids[] = $user->getId();
     }
     // only companies with users
开发者ID:rorteg,项目名称:fengoffice,代码行数:67,代码来源:TaskController.class.php

示例3: format_value_to_print

function format_value_to_print($col, $value, $type, $obj_type_id, $textWrapper = '', $dateformat = 'Y-m-d')
{
    switch ($type) {
        case DATA_TYPE_STRING:
            if (preg_match(EMAIL_FORMAT, strip_tags($value))) {
                $formatted = strip_tags($value);
            } else {
                if ($col == 'is_user') {
                    $formatted = $value == 1 ? lang('yes') : lang('no');
                } else {
                    if (strpos($value, "�") !== false) {
                        $value = preg_replace('/\\xA0/s', ' ', $value);
                    }
                    $value = utf8_safe($value);
                    $formatted = $textWrapper . $value . $textWrapper;
                }
            }
            break;
        case DATA_TYPE_INTEGER:
            if ($col == 'priority') {
                switch ($value) {
                    case 100:
                        $formatted = lang('low priority');
                        break;
                    case 200:
                        $formatted = lang('normal priority');
                        break;
                    case 300:
                        $formatted = lang('high priority');
                        break;
                    case 400:
                        $formatted = lang('urgent priority');
                        break;
                    default:
                        $formatted = clean($value);
                }
            } elseif ($col == 'time_estimate') {
                if ($value > 0) {
                    $formatted = DateTimeValue::FormatTimeDiff(new DateTimeValue(0), new DateTimeValue($value * 60), 'hm', 60);
                } else {
                    $formatted = clean($value);
                }
            } else {
                $formatted = clean($value);
            }
            break;
        case DATA_TYPE_BOOLEAN:
            $formatted = $value == 1 ? lang('yes') : lang('no');
            break;
        case DATA_TYPE_DATE:
            if ($value != 0) {
                if (str_ends_with($value, "00:00:00")) {
                    $dateformat .= " H:i:s";
                }
                try {
                    $dtVal = DateTimeValueLib::dateFromFormatAndString($dateformat, $value);
                } catch (Exception $e) {
                    $formatted = $value;
                }
                if (!isset($formatted)) {
                    $formatted = format_date($dtVal, null, 0);
                }
            } else {
                $formatted = '';
            }
            break;
        case DATA_TYPE_DATETIME:
            if ($value != 0) {
                try {
                    $dtVal = DateTimeValueLib::dateFromFormatAndString("{$dateformat} H:i:s", $value);
                } catch (Exception $e) {
                    $formatted = $value;
                }
                if ($dtVal instanceof DateTimeValue) {
                    if ($obj_type_id == ProjectEvents::instance()->getObjectTypeId() || $obj_type_id == ProjectTasks::instance()->getObjectTypeId()) {
                        $dtVal->advance(logged_user()->getTimezone() * 3600, true);
                    }
                    if ($obj_type_id == ProjectEvents::instance()->getObjectTypeId() && ($col == 'start' || $col == 'duration')) {
                        $formatted = format_datetime($dtVal);
                    } else {
                        $formatted = format_date($dtVal, null, 0);
                    }
                }
            } else {
                $formatted = '';
            }
            break;
        default:
            $formatted = $value;
    }
    if ($formatted == '') {
        $formatted = '--';
    }
    return $formatted;
}
开发者ID:abhinay100,项目名称:feng_app,代码行数:95,代码来源:format.php

示例4: _findAllowed

 /**
  * @deprecated
  * @author Ignacio Vazquez - elpepe.uy@gmail.com
  */
 static function _findAllowed()
 {
     //1.  Find members where user can add tasks
     //$sqlMembers = "
     $sql = "\n\t\t\tSELECT distinct(id) AS id\n\t\t\tFROM " . TABLE_PREFIX . "object_members om\n\t\t\tINNER JOIN " . TABLE_PREFIX . "templates t ON t.object_id = om.object_id\n\t\t\tINNER JOIN " . TABLE_PREFIX . "objects o ON om.object_id = o.id\n\t\t\tWHERE\n\t\t\t    member_id IN (  \n\t\t\t    \tSELECT distinct(member_id) \n\t\t\t\t\tFROM " . TABLE_PREFIX . "contact_member_permissions o \n\t\t\t\t\tWHERE object_type_id = " . ProjectTasks::instance()->getObjectTypeId() . " \n\t\t\t\t\tAND permission_group_id IN ( " . ContactPermissionGroups::getPermissionGroupIdsByContactCSV(logged_user()->getId()) . " ) AND can_write= 1 \n\t\t\t\t)\n\t\t\t\tAND is_optimization = 0\n\t\t\tGROUP BY om.object_id\t\t\n\t\t";
     $res = DB::execute($sql);
     $tpls = array();
     // Iterate on the results and make som filtering
     while ($row = $res->fetchRow()) {
         $tpl = COTemplates::instance()->findById($row['id']);
         $tpls[] = $tpl;
     }
     return $tpls;
 }
开发者ID:rorteg,项目名称:fengoffice,代码行数:18,代码来源:COTemplates.class.php

示例5: manager

        /**
	 * Return manager instance
	 *
	 * @access protected
	 * @param void
	 * @return ProjectTasks
	 */
	function manager() {
		if(!($this->manager instanceof ProjectTasks)) $this->manager = ProjectTasks::instance();
		return $this->manager;
	} // manager
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:11,代码来源:BaseProjectTask.class.php

示例6: lang

if (!(isset($tasks) || $userPreferences['groupBy'] == 'milestone')) {
    ?>
			<div style="font-size:130%;width:100%;text-align:center;padding-top:10px;color:#777;"><?php 
    echo lang('no tasks to display');
    ?>
</div>
	<?php 
}
?>
		</div>
	</div>
</div>

<script type="text/javascript">
	if (!ogTasks.tasks_object_type_id) ogTasks.tasks_object_type_id = '<?php 
echo ProjectTasks::instance()->getObjectTypeId();
?>
';
	if (rx__TasksDrag)
		rx__TasksDrag.initialize();

	ogTasks.userPreferences = Ext.util.JSON.decode(document.getElementById('hfUserPreferences').value);

	var mili = 0;
	if (og.TasksTopToolbar == 'undefined') {
		mili = 500;
	}

	// to prevent js execution before the js files are received
	setTimeout(function () {
		var ogTasksTT = new og.TasksTopToolbar({
开发者ID:rorteg,项目名称:fengoffice,代码行数:31,代码来源:new_list_tasks.php

示例7: new_list_tasks

 function new_list_tasks()
 {
     //load config options into cache for better performance
     load_user_config_options_by_category_name('task panel');
     // get query parameters, save user preferences if necessary
     $status = array_var($_GET, 'status', null);
     if (is_null($status) || $status == '') {
         $status = user_config_option('task panel status', 2);
     } else {
         if (user_config_option('task panel status') != $status) {
             set_user_config_option('task panel status', $status, logged_user()->getId());
         }
     }
     $previous_filter = user_config_option('task panel filter', 'assigned_to');
     $filter = array_var($_GET, 'filter');
     if (is_null($filter) || $filter == '') {
         $filter = user_config_option('task panel filter', 'assigned_to');
     } else {
         if (user_config_option('task panel filter') != $filter) {
             set_user_config_option('task panel filter', $filter, logged_user()->getId());
         }
     }
     if ($filter != 'no_filter') {
         $filter_value = array_var($_GET, 'fval');
         if (is_null($filter_value) || $filter_value == '') {
             $filter_value = user_config_option('task panel filter value', logged_user()->getCompanyId() . ':' . logged_user()->getId());
             set_user_config_option('task panel filter value', $filter_value, logged_user()->getId());
             $filter = $previous_filter;
             set_user_config_option('task panel filter', $filter, logged_user()->getId());
         } else {
             if (user_config_option('task panel filter value') != $filter_value) {
                 set_user_config_option('task panel filter value', $filter_value, logged_user()->getId());
             }
         }
     }
     $isJson = array_var($_GET, 'isJson', false);
     if ($isJson) {
         ajx_current("empty");
     }
     $project = active_project();
     $tag = active_tag();
     $template_condition = "`is_template` = 0 ";
     //Get the task query conditions
     $task_filter_condition = "";
     switch ($filter) {
         case 'assigned_to':
             $assigned_to = explode(':', $filter_value);
             $assigned_to_user = array_var($assigned_to, 1, 0);
             $assigned_to_company = array_var($assigned_to, 0, 0);
             if ($assigned_to_user > 0) {
                 $task_filter_condition = " AND (`assigned_to_user_id` = " . $assigned_to_user . " OR (`assigned_to_company_id` = " . $assigned_to_company . " AND `assigned_to_user_id` = 0)) ";
             } else {
                 if ($assigned_to_company > 0) {
                     $task_filter_condition = " AND  `assigned_to_company_id` = " . $assigned_to_company . " AND `assigned_to_user_id` = 0";
                 } else {
                     if ($assigned_to_company == -1 && $assigned_to_user == -1) {
                         $task_filter_condition = "  AND `assigned_to_company_id` = 0 AND `assigned_to_user_id` = 0 ";
                     }
                 }
             }
             break;
         case 'assigned_by':
             if ($filter_value != 0) {
                 $task_filter_condition = " AND  `assigned_by_id` = " . $filter_value . " ";
             }
             break;
         case 'created_by':
             if ($filter_value != 0) {
                 $task_filter_condition = " AND  `created_by_id` = " . $filter_value . " ";
             }
             break;
         case 'completed_by':
             if ($filter_value != 0) {
                 $task_filter_condition = " AND  `completed_by_id` = " . $filter_value . " ";
             }
             break;
         case 'milestone':
             $task_filter_condition = " AND  `milestone_id` = " . $filter_value . " ";
             break;
         case 'priority':
             $task_filter_condition = " AND  `priority` = " . $filter_value . " ";
             break;
         case 'subtype':
             if ($filter_value != 0) {
                 $task_filter_condition = " AND  `object_subtype` = " . $filter_value . " ";
             }
             break;
         case 'no_filter':
             $task_filter_condition = "";
             break;
         default:
             flash_error(lang('task filter criteria not recognised', $filter));
     }
     if ($project instanceof Project) {
         $pids = $project->getAllSubWorkspacesQuery(true);
         $projectstr = " AND " . ProjectTasks::getWorkspaceString($pids);
     } else {
         $pids = "";
         $projectstr = "";
     }
//.........这里部分代码省略.........
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:101,代码来源:TaskController.class.php

示例8: add_custom_properties

 /**
  * Adds the custom properties of an object into the database.
  * 
  * @param $object
  * @return unknown_type
  */
 function add_custom_properties($object)
 {
     if (logged_user()->isGuest()) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     $obj_custom_properties = array_var($_POST, 'object_custom_properties');
     if (is_array($obj_custom_properties)) {
         foreach ($obj_custom_properties as $id => &$val) {
             $val = remove_scripts($val);
         }
     }
     $date_format = user_config_option('date_format');
     $date_format_tip = date_format_tip($date_format);
     $required_custom_props = array();
     $object_type_id = $object instanceof TemplateTask ? ProjectTasks::instance()->getObjectTypeId() : $object->getObjectTypeId();
     $customProps = CustomProperties::getAllCustomPropertiesByObjectType($object_type_id);
     //Sets all boolean custom properties to 0. If any boolean properties are returned, they are subsequently set to 1.
     foreach ($customProps as $cp) {
         if ($cp->getType() == 'boolean') {
             $custom_property_value = CustomPropertyValues::getCustomPropertyValue($object->getId(), $cp->getId());
             if (!$custom_property_value instanceof CustomPropertyValue) {
                 $custom_property_value = new CustomPropertyValue();
             }
             $custom_property_value->setObjectId($object->getId());
             $custom_property_value->setCustomPropertyId($cp->getId());
             $custom_property_value->setValue(0);
             $custom_property_value->save();
         }
         if ($cp->getIsRequired()) {
             $required_custom_props[] = $cp;
         }
     }
     foreach ($required_custom_props as $req_cp) {
         if (!isset($obj_custom_properties[$req_cp->getId()])) {
             throw new Exception(lang('custom property value required', $req_cp->getName()));
         }
     }
     if (is_array($obj_custom_properties)) {
         // check required custom properties
         foreach ($obj_custom_properties as $id => $value) {
             //Get the custom property
             $custom_property = null;
             foreach ($customProps as $cp) {
                 if ($cp->getId() == $id) {
                     $custom_property = $cp;
                     break;
                 }
             }
             if ($custom_property instanceof CustomProperty) {
                 // save dates in standard format "Y-m-d H:i:s", because the column type is string
                 if ($custom_property->getType() == 'date') {
                     if (is_array($value)) {
                         $newValues = array();
                         foreach ($value as $val) {
                             if (trim($val) != '' && trim($val) != $date_format_tip) {
                                 $dtv = DateTimeValueLib::dateFromFormatAndString($date_format, $val);
                                 $newValues[] = $dtv->format("Y-m-d H:i:s");
                             }
                         }
                         $value = $newValues;
                     } else {
                         if (trim($value) != '' && trim($val) != $date_format_tip) {
                             $dtv = DateTimeValueLib::dateFromFormatAndString($date_format, $value);
                             $value = $dtv->format("Y-m-d H:i:s");
                         } else {
                             $value = '';
                         }
                     }
                 }
                 foreach (array_var($_REQUEST, 'remove_custom_properties', array()) as $cpropid => $remove) {
                     if ($remove) {
                         CustomPropertyValues::deleteCustomPropertyValues($object->getId(), $cpropid);
                     }
                 }
                 Hook::fire('before_save_custom_property_value', array('custom_prop' => $custom_property), $value);
                 if (is_array($value)) {
                     if ($custom_property->getType() == 'address') {
                         if ($custom_property->getIsRequired()) {
                             if (array_var($value, 'street') == '' && array_var($value, 'city') == '' && array_var($value, 'state') == '' && array_var($value, 'country') == '' && array_var($value, 'zip_code') == '') {
                                 throw new Exception(lang('custom property value required', $custom_property->getName()));
                             }
                             $errors = array(lang('error form validation'));
                             Env::useHelper('form');
                             $ok = checkAddressInputMandatoryFields($value, $custom_property->getName(), $errors);
                             if (!$ok) {
                                 throw new Exception(implode("\n - ", $errors));
                             }
                         }
                         // Address custom property
                         $val = array_var($value, 'type') . '|' . array_var($value, 'street') . '|' . array_var($value, 'city') . '|' . array_var($value, 'state') . '|' . array_var($value, 'country') . '|' . array_var($value, 'zip_code');
                         CustomPropertyValues::deleteCustomPropertyValues($object->getId(), $id);
                         $custom_property_value = new CustomPropertyValue();
//.........这里部分代码省略.........
开发者ID:abhinay100,项目名称:feng_app,代码行数:101,代码来源:ObjectController.class.php

示例9: move_inconsistent_tasks

 /**
  * Moves the tasks that do not comply with the following rule: Tasks of a milestone must belong to its workspace or any of its subworkspaces.
  * 
  * @param Project $newWorkspace The new workspace
  * @return unknown_type
  */
 function move_inconsistent_tasks(Project $newWorkspace)
 {
     $oldWorkspace = $this->getProject();
     $nwCSV = explode(',', $newWorkspace->getAllSubWorkspacesCSV(true));
     $owCSV = explode(',', $oldWorkspace->getAllSubWorkspacesCSV(true));
     $inconsistentWs = array();
     foreach ($owCSV as $ow) {
         $found = false;
         foreach ($nwCSV as $nw) {
             if ($ow == $nw) {
                 $found = true;
                 break;
             }
         }
         if (!$found) {
             $inconsistentWs[] = $ow;
         }
     }
     if (count($inconsistentWs) > 0) {
         try {
             DB::execute('UPDATE ' . WorkspaceObjects::instance()->getTableName(true) . ' SET workspace_id = ' . $newWorkspace->getId() . ' WHERE object_manager = \'ProjectTasks\' and object_id in (SELECT id from ' . ProjectTasks::instance()->getTableName(true) . ' WHERE milestone_id = ' . $this->getId() . ') and workspace_id in (' . implode(',', $inconsistentWs) . ')');
         } catch (Exception $e) {
             throw $e;
         }
         // try
     }
 }
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:33,代码来源:ProjectMilestone.class.php

示例10: getRangeTasksByUser

 /**
  * Return Day tasks this user have access on
  *
  * @access public
  * @param void
  * @return array
  */
 function getRangeTasksByUser(DateTimeValue $date_start, DateTimeValue $date_end, $assignedUser, $tags = '', $project = null, $archived = false)
 {
     $from_date = new DateTimeValue($date_start->getTimestamp());
     $from_date = $from_date->beginningOfDay();
     $to_date = new DateTimeValue($date_end->getTimestamp());
     $to_date = $to_date->endOfDay();
     $permissions = ' AND ( ' . permissions_sql_for_listings(ProjectTasks::instance(), ACCESS_LEVEL_READ, logged_user(), 'project_id') . ')';
     if ($project instanceof Project) {
         $pids = $project->getAllSubWorkspacesQuery(!$archived);
         $wsstring = " AND " . self::getWorkspaceString($pids);
     } else {
         $wsstring = "";
     }
     if (isset($tags) && $tags && $tags != '') {
         $tag_str = " AND exists (SELECT * from " . TABLE_PREFIX . "tags t WHERE tag=" . DB::escape($tags) . " AND  " . TABLE_PREFIX . "project_tasks.id=t.rel_object_id AND t.rel_object_manager='ProjectTasks') ";
     } else {
         $tag_str = "";
     }
     $assignedFilter = '';
     if ($assignedUser instanceof User) {
         $assignedFilter = ' AND (`assigned_to_user_id` = ' . $assignedUser->getId() . ' OR (`assigned_to_user_id` = 0 AND `assigned_to_company_id` = ' . $assignedUser->getCompanyId() . ')) ';
     }
     $rep_condition = " (`repeat_forever` = 1 OR `repeat_num` > 0 OR (`repeat_end` > 0 AND `repeat_end` >= '" . $from_date->toMySQL() . "')) ";
     if ($archived) {
         $archived_cond = " AND `archived_by_id` <> 0";
     } else {
         $archived_cond = " AND `archived_by_id` = 0";
     }
     $result = self::findAll(array('conditions' => array('`is_template` = false AND `completed_on` = ? AND ((`due_date` >= ? AND `due_date` < ?) OR (`start_date` >= ? AND `start_date` < ?) OR ' . $rep_condition . ') ' . $archived_cond . $assignedFilter . $permissions . $wsstring . $tag_str, EMPTY_DATETIME, $from_date, $to_date, $from_date, $to_date)));
     // findAll
     return $result;
 }
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:39,代码来源:ProjectTasks.class.php

示例11: can_add_to_member

/**
 * Return true if $user can add an object of type $object_type_id in $member. False otherwise.
 *
 * @param Contact $user
 * @param Member $member
 * @param array $context_members
 * @param $object_type_id
 * @return boolean
 */
function can_add_to_member(Contact $user, $member, $context_members, $object_type_id, $check_dimension = true)
{
    if (TemplateTasks::instance()->getObjectTypeId() == $object_type_id) {
        $object_type_id = ProjectTasks::instance()->getObjectTypeId();
    }
    if (TemplateMilestones::instance()->getObjectTypeId() == $object_type_id) {
        $object_type_id = ProjectMilestones::instance()->getObjectTypeId();
    }
    if (!$member instanceof Member && is_array($member) && isset($member['id'])) {
        $member = Members::findById($member['id']);
    }
    if ($user->isGuest() || !$member || !$member->canContainObject($object_type_id)) {
        return false;
    }
    try {
        $contact_pg_ids = ContactPermissionGroups::getPermissionGroupIdsByContactCSV($user->getId(), false);
        if ($check_dimension) {
            $dimension = $member->getDimension();
        }
        //dimension does not define permissions - user can freely add in all members
        if ($check_dimension && !$dimension->getDefinesPermissions()) {
            return true;
        }
        //dimension defines permissions and user has maximum level of permissions so can freely in all members
        if ($check_dimension && $dimension->hasAllowAllForContact($contact_pg_ids)) {
            return true;
        }
        //check
        if (ContactMemberPermissions::contactCanReadObjectTypeinMember($contact_pg_ids, $member->getId(), $object_type_id, true, false, $user)) {
            $max_role_ot_perm = MaxRoleObjectTypePermissions::instance()->findOne(array('conditions' => "object_type_id='{$object_type_id}' AND role_id = '" . $user->getUserType() . "'"));
            // if user max permission cannot write this object type then return false
            if ($max_role_ot_perm && $max_role_ot_perm->getCanWrite()) {
                return true;
            } else {
                return false;
            }
        }
        //check for context permissions that allow user to add in this member
        if ($context_members) {
            $member_ids = array();
            foreach ($context_members as $member_obj) {
                $member_ids[] = $member_obj->getId();
            }
            $allowed_members = ContactMemberPermissions::getActiveContextPermissions($user, $object_type_id, $context_members, $member_ids, true);
            if (in_array($member, $allowed_members)) {
                return true;
            }
        }
    } catch (Exception $e) {
        tpl_assign('error', $e);
        return false;
    }
    return false;
}
开发者ID:abhinay100,项目名称:feng_app,代码行数:63,代码来源:permissions.php

示例12: gen_id

<?php

$genid = gen_id();
$limit = 20;
$total = $limit;
$page = 10;
$task_assignment_conditions = "";
if (!SystemPermissions::userHasSystemPermission(logged_user(), 'can_see_assigned_to_other_tasks')) {
    $task_assignment_conditions = " AND assigned_to_contact_id = " . logged_user()->getId();
}
$tasks_result = ProjectTasks::instance()->listing(array("order" => "completed_on", "order_dir" => "DESC", "extra_conditions" => " AND is_template = 0 AND completed_by_id > 0 {$task_assignment_conditions}", "limit" => $limit + 1));
$tasks = $tasks_result->objects;
$active_members = array();
$context = active_context();
if (is_array($context)) {
    foreach ($context as $selection) {
        if ($selection instanceof Member) {
            $active_members[] = $selection;
        }
    }
}
if (count($active_members) > 0) {
    $mnames = array();
    $allowed_contact_ids = array();
    foreach ($active_members as $member) {
        $mnames[] = clean($member->getName());
    }
    $widget_title = lang('completed tasks') . ' ' . lang('in') . ' ' . implode(", ", $mnames);
}
if ($tasks_result->total > 0) {
    include 'template.php';
开发者ID:abhinay100,项目名称:feng_app,代码行数:31,代码来源:index.php

示例13: canAdd

	function canAdd(Contact $user, $context, &$notAllowedMember = ''){
		return can_add($user, $context, ProjectTasks::instance()->getObjectTypeId(), $notAllowedMember);
	}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:3,代码来源:ProjectTask.class.php

示例14: allowed_users_to_assign_all

function allowed_users_to_assign_all($context = null)
{
    if ($context == null) {
        $context = active_context();
    }
    // only companies with users
    $companies = Contacts::findAll(array("conditions" => "e.is_company = 1 AND EXISTS (SELECT object_id FROM " . TABLE_PREFIX . "contacts WHERE is_company = 0 AND user_type > 0 AND company_id = o.id  )", "join" => array("table" => Contacts::instance()->getTableName(), "jt_field" => "object_id", "j_sub_q" => "SELECT xx.object_id FROM " . Contacts::instance()->getTableName(true) . " xx WHERE xx.is_company=0 AND xx.company_id = e.object_id LIMIT 1"), "order" => "name"));
    $comp_ids = array("0");
    $comp_array = array("0" => array('id' => "0", 'name' => lang('without company'), 'users' => array()));
    foreach ($companies as $company) {
        $comp_ids[] = $company->getId();
        $comp_array[$company->getId()] = array('id' => $company->getId(), 'name' => $company->getObjectName(), 'users' => array());
    }
    if (!can_manage_tasks(logged_user()) && can_task_assignee(logged_user())) {
        $contacts = array(logged_user());
    } else {
        if (can_manage_tasks(logged_user())) {
            $contacts = allowed_users_in_context(ProjectTasks::instance()->getObjectTypeId(), $context, ACCESS_LEVEL_READ, "AND `is_company`=0 AND `company_id` IN (" . implode(",", $comp_ids) . ")");
        } else {
            $contacts = array();
        }
    }
    foreach ($contacts as $contact) {
        /* @var $contact Contact */
        if (TabPanelPermissions::instance()->count(array("conditions" => "permission_group_id = " . $contact->getPermissionGroupId() . " AND tab_panel_id = 'tasks-panel' "))) {
            $comp_array[]['users'][] = array('id' => $contact->getId(), 'name' => $contact->getObjectName(), 'isCurrent' => $contact->getId() == logged_user()->getId());
        }
    }
    return array_values($comp_array);
}
开发者ID:rorteg,项目名称:fengoffice,代码行数:30,代码来源:application.php

示例15: save_object

 private function save_object($request)
 {
     $response = false;
     if (!empty($request['args'])) {
         $service = $request['srv'];
         switch ($service) {
             case "task":
                 if ($request['args']['id']) {
                     $object = ProjectTasks::instance()->findByid($request['args']['id']);
                 } else {
                     $object = new ProjectTask();
                 }
                 if ($object instanceof ProjectTask) {
                     if (!empty($request['args']['title'])) {
                         $object->setObjectName($request['args']['title']);
                     }
                     if (!empty($request['args']['description'])) {
                         $object->setText($request['args']['description']);
                     }
                     if (!empty($request['args']['due_date'])) {
                         if ($request['args']['due_date'] != '' && $request['args']['due_date'] != date_format_tip('dd/mm/yyyy')) {
                             $date_format = 'dd/mm/yyyy';
                             $object->setDueDate(DateTimeValueLib::dateFromFormatAndString($date_format, $value));
                         }
                     }
                     if (!empty($request['args']['completed'])) {
                         $object->setPercentCompleted($request['args']['completed']);
                     }
                     if (!empty($request['args']['assign_to'])) {
                         $object->setAssignedToContactId($request['args']['assign_to']);
                     }
                     if (!empty($request['args']['priority'])) {
                         $object->setPriority($request['args']['priority']);
                     }
                 }
                 break;
             case 'note':
                 if ($request['args']['id']) {
                     $object = ProjectMessages::instance()->findByid($request['args']['id']);
                 } else {
                     $object = new ProjectMessage();
                 }
                 if ($object instanceof ProjectMessage) {
                     if (!empty($request['args']['title'])) {
                         $object->setObjectName($request['args']['title']);
                     }
                     if (!empty($request['args']['title'])) {
                         $object->setText($request['args']['text']);
                     }
                 }
                 break;
         }
         // END SWITCH
         if ($object) {
             try {
                 $context = array();
                 $members = array();
                 if (!empty($request['args']['members'])) {
                     $members = $request['args']['members'];
                     $context = get_context_from_array($members);
                 }
                 //Check permissions:
                 if ($request['args']['id'] && $object->canEdit(logged_user()) || !$request['args']['id'] && $object->canAdd(logged_user(), $context)) {
                     DB::beginWork();
                     $object->save();
                     $object_controller = new ObjectController();
                     if (!$request['args']['id']) {
                         $object_controller->add_to_members($object, $members);
                     }
                     DB::commit();
                     $response = true;
                 }
             } catch (Exception $e) {
                 DB::rollback();
                 return false;
             }
         }
     }
     return $this->response('json', $response);
 }
开发者ID:abhinay100,项目名称:feng_app,代码行数:80,代码来源:ApiController.class.php


注:本文中的ProjectTasks::instance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。