Exemplo n.º 1
0
function updategroupnotify_POST(Web &$w)
{
    // lets get some values knowing that only checked checkboxes return a value
    $arr['guest']['creator'] = $_REQUEST['guest_creator'] ? $_REQUEST['guest_creator'] : "0";
    $arr['member']['creator'] = $_REQUEST['member_creator'] ? $_REQUEST['member_creator'] : "0";
    $arr['member']['assignee'] = $_REQUEST['member_assignee'] ? $_REQUEST['member_assignee'] : "0";
    $arr['owner']['creator'] = $_REQUEST['owner_creator'] ? $_REQUEST['owner_creator'] : "0";
    $arr['owner']['assignee'] = $_REQUEST['owner_assignee'] ? $_REQUEST['owner_assignee'] : "0";
    $arr['owner']['other'] = $_REQUEST['owner_other'] ? $_REQUEST['owner_other'] : "0";
    // so foreach role/type lets put the values in the database
    foreach ($arr as $role => $types) {
        foreach ($types as $type => $value) {
            // is there a record for this taskgroup > role > type?
            $notify = $w->Task->getTaskGroupNotifyType($_REQUEST['task_group_id'], $role, $type);
            // if yes, update, if no, insert
            if ($notify) {
                $notify->value = $value;
                $notify->update();
            } else {
                $notify = new TaskGroupNotify($w);
                $notify->task_group_id = $_REQUEST['task_group_id'];
                $notify->role = $role;
                $notify->type = $type;
                $notify->value = $value;
                $notify->insert();
            }
        }
    }
    // return
    $w->msg("Notifications Updated", "/task-group/viewmembergroup/" . $_REQUEST['task_group_id'] . "/?tab=2");
}
Exemplo n.º 2
0
 /**
  * Create a new Taskgroup using all the form details of the taskgroup form
  * 
  * @param task_group_type, eg. "TaskGroupType_TaskTodo"
  * @param title, the task group title
  * @param description, a description
  * @param default_assignee_id, a user_id or null
  * @param can_assign, OWNER|MEMBER|GUEST
  * @param can_view, OWNER|MEMBER|GUEST
  * @param can_create, OWNER|MEMBER|GUEST
  * @param is_active, 0|1
  * @param is_deleted, 0|1
  *  
  * @return TaskGroup
  */
 function createTaskGroup($type, $title, $description, $default_assignee_id, $can_assign = "OWNER", $can_view = "OWNER", $can_create = "OWNER", $is_active = 1, $is_deleted = 0)
 {
     // title should be unique!
     $taskgroup = $this->getTaskGroupByUniqueTitle($title);
     if (null != $taskgroup) {
         return $taskgroup;
     }
     // insert newly created task group into the task_group database
     $taskgroup = new TaskGroup($this->w);
     $taskgroup->task_group_type = $type;
     $taskgroup->title = $title;
     $taskgroup->description = $description;
     $taskgroup->can_assign = $can_assign;
     $taskgroup->can_view = $can_view;
     $taskgroup->can_create = $can_create;
     $taskgroup->is_active = $is_active;
     $taskgroup->is_deleted = $is_deleted;
     $taskgroup->default_assignee_id = $default_assignee_id;
     $response = $taskgroup->insert();
     // Check the validation
     if ($response !== true) {
         $this->w->errorMessage($taskgroup, "Taskgroup", $response, false, "/task-group/viewtaskgrouptypes#create");
     }
     // if created succcessfully, create default notify matrix: all on
     if ($taskgroup->id) {
         $arr['guest']['creator'] = 1;
         $arr['member']['creator'] = 1;
         $arr['member']['assignee'] = 1;
         $arr['owner']['creator'] = 1;
         $arr['owner']['assignee'] = 1;
         $arr['owner']['other'] = 1;
         // so foreach role/type lets put the values in the database
         foreach ($arr as $role => $types) {
             foreach ($types as $type => $value) {
                 $notify = new TaskGroupNotify($this->w);
                 $notify->task_group_id = $taskgroup->id;
                 $notify->role = $role;
                 $notify->type = $type;
                 $notify->value = $value;
                 $notify->insert();
             }
         }
     }
     // if task group is successfully created and a default assignee is defined
     // create a task group membership list and set this person as the task group owner
     // if no default assignee, a task group membership list can be created at any time
     if ($taskgroup->id && $default_assignee_id != "") {
         $arrdb = array();
         $arrdb['task_group_id'] = $taskgroup->id;
         $arrdb['user_id'] = $default_assignee_id;
         $arrdb['role'] = "OWNER";
         $arrdb['priority'] = 1;
         $arrdb['is_active'] = 1;
         $mem = new TaskGroupMember($this->w);
         $mem->fill($arrdb);
         $mem->insert();
     }
     return $taskgroup;
 }