Beispiel #1
0
 /**
  * additional data preparations for __tasksView() data
  *
  */
 function __prepTasksView($thedata = '')
 {
     //profiling
     $this->data['controller_profiling'][] = __FUNCTION__;
     //check if data is not empty
     if (count($thedata) == 0 || !is_array($thedata)) {
         return $thedata;
     }
     /* -----------------------PREPARE TASKS DATA ----------------------------------------/
      *  Loop through all the tasks in this array and for each task:
      *  -----------------------------------------------------------
      *  (1) add visibility for the [control] buttons
      *  (2) process user names (task assigned to)
      *  -----------------------------------------------------------
      *
      * [NOTES]
      * Usage is during conditional loading at TBS->MERGEBLOCK level and should be as follows:
      * <!--[onshow;block=div;when [tasks.wi_tasks_timer_buttons;block=tr] == 1;comm]-->
      * --AS OPPOSED TO--
      * <!--[onshow;block=div;when [tasks.wi_tasks_timer_buttons] == 1;comm]-->
      *
      *------------------------------------------------------------------------------------*/
     for ($i = 0; $i < count($thedata); $i++) {
         //--------------------(1) VISIBILITY OF EDIT AND DELETE BUTTON------------------------------\\
         //first set visibility to 0
         $visible_delete_button = 0;
         $visible_edit_button = 0;
         //task is assigned to me and I have edit rights
         if ($thedata[$i]['tasks_assigned_to_id'] == $this->data['vars']['my_id']) {
             //align with my general permissions
             $visible_delete_button = $this->data['project_permissions']['delete_item_my_project_my_tasks'];
             $visible_edit_button = $this->data['project_permissions']['edit_item_my_project_my_tasks'];
         }
         //i am project leader or admininstrator
         if ($this->data['vars']['my_id'] == $this->data['vars']['project_leaders_id'] || $this->data['my_group'] == 1) {
             $visible_delete_button = 1;
             $visible_edit_button = 1;
         }
         //inject control visibility into $thedata array
         $thedata[$i]['visible_delete_button'] = $visible_delete_button;
         $thedata[$i]['visible_edit_button'] = $visible_edit_button;
         //-----(2) PROCESS (ASSIGNED TO) USER NAMES------------------------------\\
         if ($thedata[$i]['team_profile_full_name'] != '') {
             //trim max lenght
             $fullname = trim_string_length($thedata[$i]['team_profile_full_name'], 10);
             $user_id = $thedata[$i]['team_profile_id'];
             //create users name label
             $thedata[$i]['assigned_to'] = '<a class="links-blue iframeModal"
                                                   data-height="250" 
                                                   data-width="100%"
                                                   data-toggle="modal"
                                                   data-target="#modalIframe"
                                                   data-modal-window-title="' . $this->data['lang']['lang_user_profile'] . '" 
                                                   data-src="' . site_url("admin/people/team/{$user_id}") . '"
                                                   href="#">' . $fullname . '</a>';
         } else {
             //this user is unavailable (has been deleted etc)
             $thedata[$i]['assigned_to'] = '<a class="tooltips" 
                                                    data-original-title="' . $this->data['lang']['lang_userd_details_unavailable'] . '">
                                                    ' . $this->data['lang']['lang_unavailable'] . '</a>';
         }
     }
     //return the processed array
     return $thedata;
 }
Beispiel #2
0
 /**
  * additional data preparations for [message replies]
  *
  */
 function __prepMessageReplies($thedata = '')
 {
     //profiling
     $this->data['controller_profiling'][] = __FUNCTION__;
     //check if data is not empty
     if (count($thedata) == 0 || !is_array($thedata)) {
         return $thedata;
     }
     /* -----------------------PREPARE FILES DATA ----------------------------------------/
      *  Loop through all the files in this array and for each file:
      *  -----------------------------------------------------------
      *  (1) add visibility for the [control] buttons
      *  (2) process user names (message posted by)
      *  (3) strip unwanted html tags from message_text
      *  (4) process avatar images
      *  -----------------------------------------------------------
      *  (1) above is base on what rights I have on the message, i.e:
      *           - am I the message poster
      *           - am I the project leader
      *           - am I a system administrator
      *
      * [NOTES]
      * Usage is during conditional loading at TBS->MERGEBLOCK level and should be as follows:
      * <!--[onshow;block=div;when [files.wi_files_control_buttons;block=tr] == 1;comm]-->
      * --AS OPPOSED TO--
      * <!--[onshow;block=div;when [files.wi_files_control_buttons] == 1;comm]-->
      *
      *------------------------------------------------------------------------------------*/
     for ($i = 0; $i < count($thedata); $i++) {
         //-----(1) VISIBILITY OF CONTROL BUTTONS--------------------------------\\
         //default visibility
         $visibility_control = 0;
         //grant rights if I am the one who posted the message
         if ($this->data['vars']['my_id'] == $thedata[$i]['messages_replies_by_id']) {
             $visibility_control = 1;
         }
         //grant visibility if I am an admin or I am the project leader
         if ($this->data['vars']['my_group'] == 1 || $this->data['vars']['my_id'] == $this->data['vars']['project_leaders_id']) {
             $visibility_control = 1;
         }
         //add my rights into $thedata array
         $thedata[$i]['wi_messages_replies_control_buttons'] = $visibility_control;
         //-----(2) PROCESS (TEAM/CLIENT) USER NAMES--------------------------------\\
         //--team member---------------------
         if ($thedata[$i]['messages_replies_by'] == 'team') {
             //is the users data available
             if ($thedata[$i]['team_profile_full_name'] != '') {
                 //trim max lenght
                 $fullname = trim_string_length($thedata[$i]['team_profile_full_name'], 20);
                 $user_id = $thedata[$i]['team_profile_id'];
                 //create users name label
                 $thedata[$i]['uploaded_by'] = '<a class="links-blue iframeModal"
                                                   data-height="250" 
                                                   data-width="100%"
                                                   data-toggle="modal"
                                                   data-target="#modalIframe"
                                                   data-modal-window-title="' . $this->data['lang']['lang_user_profile'] . '" 
                                                   data-src="' . site_url("client/people/team/{$user_id}") . '"
                                                   href="#">' . $fullname . '</a>';
             } else {
                 //this user is unavailable (has been deleted etc)
                 $thedata[$i]['uploaded_by'] = '<span class="tooltips" 
                                                    data-original-title="' . $this->data['lang']['lang_userd_details_unavailable'] . '">
                                                    ' . $this->data['lang']['lang_unavailable'] . '</span>';
             }
         }
         //--client user----------------------
         if ($thedata[$i]['messages_replies_by'] == 'client') {
             //is the users data available
             if ($thedata[$i]['client_users_full_name'] != '') {
                 //trim max lenght
                 $fullname = trim_string_length($thedata[$i]['client_users_full_name'], 20);
                 $user_id = $thedata[$i]['client_users_id'];
                 //create html
                 $thedata[$i]['uploaded_by'] = '<a class="links-blue iframeModal"
                                                   data-height="250" 
                                                   data-width="100%"
                                                   data-toggle="modal"
                                                   data-target="#modalIframe"
                                                   data-modal-window-title="' . $this->data['lang']['lang_user_profile'] . '" 
                                                   data-src="' . site_url("client/people/client/{$user_id}") . '"
                                                   href="#">' . $fullname . '</a>';
             } else {
                 //this user is unavailable (has been deleted etc)
                 $thedata[$i]['uploaded_by'] = '<span class="tooltips" 
                                                    data-original-title="' . $this->data['lang']['lang_userd_details_unavailable'] . '">
                                                    ' . $this->data['lang']['lang_unavailable'] . '</span>';
             }
         }
         //-------(3) PROCESS AVATAR IMAGES----------------------------------\\
         //team member
         if ($thedata[$i]['messages_replies_by'] == 'team') {
             $thedata[$i]['avatar_filename'] = $thedata[$i]['team_profile_avatar_filename'];
         }
         //client member
         if ($thedata[$i]['messages_replies_by'] == 'client') {
             $thedata[$i]['avatar_filename'] = $thedata[$i]['client_users_avatar_filename'];
         }
         //(4) STRIP UNWANTED CKEDITOR HTML TAGS-----------------------------\\
         //remove </p> tags
         $unwanted = array('</p>');
         $thedata[$i]['messages_replies_text'] = str_replace($unwanted, '', $thedata[$i]['messages_replies_text']);
         //replace <p> with </br> tags
         $thedata[$i]['messages_replies_text'] = str_replace('<p>', '</br>', $thedata[$i]['messages_replies_text']);
     }
     //retrun the data
     return $thedata;
 }