コード例 #1
0
 /**
  * Show quick add form
  *
  * @param void
  * @return null
  */
 function quick_add()
 {
     $this->wireframe->current_menu_item = 'quick_add';
     $quick_add_urls = array();
     event_trigger('on_quick_add', array(&$quick_add_urls));
     $all_projects_permissions = array_keys($quick_add_urls);
     $formatted_map = array();
     $projects_roles_map = ProjectUsers::getProjectRolesMap($this->logged_user, array(PROJECT_STATUS_ACTIVE));
     if (!is_foreachable($projects_roles_map)) {
         print lang('There are no active projects that you are involved with');
         die;
     }
     // if
     if (is_foreachable($projects_roles_map)) {
         foreach ($projects_roles_map as $project_id => $project_role_map) {
             $formatted_map[$project_id] = array('name' => array_var($project_role_map, 'name'));
             $project_leader = array_var($project_role_map, 'leader');
             $project_role_permissions = array_var($project_role_map, 'permissions', null);
             if ($this->logged_user->isAdministrator() || $this->logged_user->isProjectManager() || $this->logged_user->getId() == $project_leader) {
                 foreach ($all_projects_permissions as $current_permission) {
                     $formatted_map[$project_id]['permissions'][] = array('title' => lang($current_permission), 'name' => $current_permission);
                 }
                 // if
             } else {
                 foreach ($all_projects_permissions as $current_permission) {
                     if (array_var($project_role_permissions, $current_permission, 0) > 1) {
                         $formatted_map[$project_id]['permissions'][] = array('title' => lang($current_permission), 'name' => $current_permission);
                     }
                     // if
                 }
                 // if
             }
             // if
         }
         // foreach
     }
     // if
     $this->smarty->assign(array('formatted_map' => $formatted_map, 'quick_add_url' => $quick_add_url, 'js_encoded_formatted_map' => do_json_encode($formatted_map), 'js_encoded_quick_add_urls' => do_json_encode($quick_add_urls)));
 }