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


PHP Project::canAdd方法代码示例

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


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

示例1: __construct

 /**
  * Construct project controller
  *
  * @param Request $request
  * @return ProjectController
  */
 function __construct($request)
 {
     parent::__construct($request);
     $this->wireframe->addBreadCrumb(lang('Projects'), assemble_url('projects'));
     $this->wireframe->current_menu_item = 'projects';
     if ($this->controller_name == 'projects' || $this->controller_name == 'project_groups') {
         if (Project::canAdd($this->logged_user)) {
             $this->wireframe->addPageAction(lang('New Project'), assemble_url('projects_add'));
         }
         // if
     }
     // if
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:19,代码来源:ProjectsController.class.php

示例2: index

 /**
  * Show dashboard overview
  *
  * @param void
  * @return null
  */
 function index()
 {
     // Welcome message, displayed only to administrators
     if ($this->logged_user->isAdministrator() && ConfigOptions::getValue('show_welcome_message')) {
         $this->wireframe->addPageAction(lang('Hide Welcome Message'), assemble_url('admin_settings_hide_welcome_message'), null, array('method' => 'post', 'confirm' => lang('You are about to hide welcome message. If you wish to bring it back later on you can do it from General settings page in Administration. Hide now?')));
         $this->smarty->assign(array('show_welcome_message' => true, 'available_modules' => Modules::findNotInstalled()));
         //BOF: task 05 | AD
         $this->wireframe->addPageAction(lang('View All'), assemble_url('view_projects_info'));
         //EOF: task 05 | AD
         // Regular dashboard
     } else {
         if (Project::canAdd($this->logged_user)) {
             $this->wireframe->addPageAction(lang('New Project'), assemble_url('projects_add'));
             //BOF: task 05 | AD
             $this->wireframe->addPageAction(lang('View All'), assemble_url('view_projects_info'));
             //EOF: task 05 | AD
         }
         // if
         $this->wireframe->addRssFeed($this->owner_company->getName() . ' - ' . lang('Recent activities'), assemble_url('rss', array('token' => $this->logged_user->getToken(true))), FEED_RSS);
         $pinned_project_ids = PinnedProjects::findProjectIdsByUser($this->logged_user);
         if (is_foreachable($pinned_project_ids)) {
             $pinned_projects = Projects::findByIds($pinned_project_ids);
         } else {
             $pinned_projects = null;
         }
         // if
         $dashboard_sections = new NamedList();
         event_trigger('on_dashboard_sections', array(&$dashboard_sections, &$this->logged_user));
         $important_items = new NamedList();
         event_trigger('on_dashboard_important_section', array(&$important_items, &$this->logged_user));
         $this->smarty->assign(array('show_welcome_message' => false, 'important_items' => $important_items, 'pinned_projects' => $pinned_projects, 'dashboard_sections' => $dashboard_sections, 'online_users' => Users::findWhoIsOnline($this->logged_user), 'grouped_activities' => group_by_date(ActivityLogs::findActiveProjectsActivitiesByUser($this->logged_user, 20), $this->logged_user)));
     }
     // if
     //BOF:mod 20110623
     $tabs = new NamedList();
     $tabs->add('dashboard', array('text' => 'Active Teams', 'url' => assemble_url('dashboard')));
     $tabs->add('home_page', array('text' => 'Home Page', 'url' => assemble_url('goto_home_tab')));
     $tabs->add('assigned_action_request', array('text' => 'Assigned Action Requests', 'url' => assemble_url('assigned_action_request')));
     $tabs->add('owned_tickets', array('text' => 'Owned Tickets', 'url' => assemble_url('my_tickets')));
     $tabs->add('subscribed_tickets', array('text' => 'Subscribed Tickets', 'url' => assemble_url('my_subscribed_tickets')));
     $this->smarty->assign('page_tabs', $tabs);
     $this->smarty->assign('page_tab', 'dashboard');
     //EOF:mod 20110623
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:50,代码来源:DashboardController.class.php

示例3: set_page_title

<?php

set_page_title(lang('my projects'));
if (Project::canAdd(logged_user())) {
    add_page_action(lang('add project'), get_url('project', 'add'), 'ico-add');
}
// if
if (isset($active_projects) && is_array($active_projects) && count($active_projects)) {
    foreach ($active_projects as $project) {
        ?>
<div class="block">
  <div class="header"><h2><a class="internalLink" href="<?php 
        echo $project->getOverviewUrl();
        ?>
"><?php 
        echo clean($project->getName());
        ?>
</a></h2></div>
  <div class="content">
<?php 
        if (trim($project->getDescription())) {
            ?>
    <div class="description"><?php 
            echo do_textile($project->getDescription());
            ?>
</div>
<?php 
        }
        // if
        if (is_array($project_companies = $project->getCompanies())) {
            $project_company_names = array();
开发者ID:abhinay100,项目名称:fengoffice_app,代码行数:31,代码来源:my_projects.php

示例4: add

 /**
  * Add project
  *
  * @param void
  * @return null
  */
 function add()
 {
     if (logged_user()->isGuest()) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     $this->setTemplate('add_project');
     if (!Project::canAdd(logged_user())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     // if
     $project = new Project();
     $project_data = array_var($_POST, 'project');
     $projects = logged_user()->getActiveProjects();
     if (active_project() instanceof Project) {
         $billing_amounts = active_project()->getBillingAmounts();
     } else {
         $billing_amounts = BillingCategories::getDefaultBillingAmounts();
     }
     tpl_assign('project', $project);
     tpl_assign('projects', $projects);
     tpl_assign('project_data', $project_data);
     tpl_assign('billing_amounts', $billing_amounts);
     // Submited...
     if (is_array($project_data)) {
         $project->setFromAttributes($project_data);
         try {
             DB::beginWork();
             $project->save();
             //Save to get the id, then update the project path info
             if (array_var($project_data, 'parent_id') != $project->getParentId()) {
                 $parent = Projects::findById(array_var($project_data, 'parent_id'));
                 if ($parent) {
                     if (!$project->canSetAsParentWorkspace($parent)) {
                         flash_error(lang('error cannot set workspace as parent', $parent->getName()));
                         ajx_current("empty");
                         return;
                     }
                 }
                 $project->setParentWorkspace($parent);
             }
             $project->save();
             /* Billing */
             $billings = array_var($project_data, 'billing', null);
             if ($billings) {
                 foreach ($billings as $billing_id => $billing) {
                     if ($billing['update'] && $billing['value'] && $billing['value'] != 0) {
                         $wb = new WorkspaceBilling();
                         $wb->setProjectId($project->getId());
                         $wb->setBillingId($billing_id);
                         $value = $billing['value'];
                         if (strpos($value, ',') && !strpos($value, '.')) {
                             $value = str_replace(',', '.', $value);
                         }
                         $wb->setValue($value);
                         $wb->save();
                     }
                 }
             }
             /* Project contacts */
             if (can_manage_contacts(logged_user())) {
                 $contacts = array_var($project_data, 'contacts', null);
                 if ($contacts) {
                     foreach ($contacts as $contact_data) {
                         $contact = Contacts::findById($contact_data['contact_id']);
                         if ($contact instanceof Contact) {
                             $pc = new ProjectContact();
                             $pc->setProjectId($project->getId());
                             $pc->setContactId($contact_data['contact_id']);
                             $pc->setRole($contact_data['role']);
                             $pc->save();
                         }
                     }
                 }
             }
             /* <permissions> */
             $permissions = null;
             $permissionsString = array_var($_POST, 'permissions');
             if ($permissionsString && $permissionsString != '') {
                 $permissions = json_decode($permissionsString);
             }
             if (is_array($permissions) && count($permissions) > 0) {
                 //Add new permissions
                 //TODO - Make batch update of these permissions
                 foreach ($permissions as $perm) {
                     if (ProjectUser::hasAnyPermissions($perm->pr, $perm->pc)) {
                         $relation = new ProjectUser();
                         $relation->setProjectId($project->getId());
                         $relation->setUserId($perm->wsid);
                         $relation->setCheckboxPermissions($perm->pc, $relation->getUserOrGroup()->isGuest() ? false : true);
                         $relation->setRadioPermissions($perm->pr, $relation->getUserOrGroup()->isGuest() ? false : true);
//.........这里部分代码省略.........
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:101,代码来源:ProjectController.class.php

示例5: add

 /**
  * Process add project form
  *
  * @param void
  * @return null
  */
 function add()
 {
     $this->wireframe->print_button = false;
     if ($this->request->isApiCall() && !$this->request->isSubmitted()) {
         $this->httpError(HTTP_ERR_BAD_REQUEST);
     }
     // if
     if (!Project::canAdd($this->logged_user)) {
         $this->httpError(HTTP_ERR_FORBIDDEN);
     }
     // if
     $project_data = $this->request->post('project');
     if (!is_array($project_data)) {
         $project_data = array('leader_id' => $this->logged_user->getId(), 'default_visibility' => VISIBILITY_PRIVATE);
     }
     // if
     $this->smarty->assign('project_data', $project_data);
     if ($this->request->isSubmitted()) {
         db_begin_work();
         $this->active_project = new Project();
         // just in case
         $this->active_project->setAttributes($project_data);
         $this->active_project->setType(PROJECT_TYPE_NORMAL);
         $this->active_project->setStatus(PROJECT_STATUS_ACTIVE);
         $leader = null;
         if ($this->active_project->getLeaderId()) {
             $leader = Users::findById($this->active_project->getLeaderId());
             if (instance_of($leader, 'User')) {
                 $this->active_project->setLeader($leader);
             }
             // if
         }
         // if
         $project_template = null;
         $project_template_id = array_var($project_data, 'project_template_id');
         if ($project_template_id) {
             $project_template = Projects::findById($project_template_id);
         }
         // if
         $save = $this->active_project->save($project_template);
         if ($save && !is_error($save)) {
             // Add user who created a project and leader
             $this->active_project->addUser($this->logged_user, null, null);
             if (instance_of($leader, 'User')) {
                 $this->active_project->addUser($leader, null, null);
             }
             // if
             // Clone project template
             if (instance_of($project_template, 'Project')) {
                 $project_template->copyItems($this->active_project);
             } else {
                 // Auto assign users...
                 $users = Users::findAutoAssignUsers();
                 if (is_foreachable($users)) {
                     foreach ($users as $user) {
                         $this->active_project->addUser($user, $user->getAutoAssignRole(), $user->getAutoAssignPermissions());
                     }
                     // foreach
                 }
                 // if
                 // Create default categories
                 $category_definitions = array();
                 event_trigger('on_master_categories', array(&$category_definitions));
                 if (is_foreachable($category_definitions)) {
                     foreach ($category_definitions as $category_definition) {
                         $default_categories = $category_definition['value'];
                         if (!is_foreachable($default_categories)) {
                             $default_categories = array('General');
                         }
                         // if
                         foreach ($default_categories as $category_name) {
                             if (trim($category_name) != '') {
                                 $category = new Category();
                                 $category->log_activities = false;
                                 // don't log stuff in DB
                                 $category->setName($category_name);
                                 $category->setProjectId($this->active_project->getId());
                                 $category->setCreatedBy($this->logged_user);
                                 $category->setState(STATE_VISIBLE);
                                 $category->setVisibility(VISIBILITY_NORMAL);
                                 $category->setModule($category_definition['module']);
                                 $category->setController($category_definition['controller']);
                                 $category->save();
                             }
                             // if
                         }
                         // foreach
                     }
                     // foreach
                 }
                 // if
             }
             // if
             db_commit();
//.........这里部分代码省略.........
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:101,代码来源:ProjectController.class.php

示例6: lang

        echo $billing_row['category']->getDefaultValue();
        ?>
</td></tr>
<?php 
    }
    //foreach
    ?>
	</table>
	</fieldset>
	</div>
	<?php 
}
?>
		
	<?php 
if (Project::canAdd(logged_user()) && isset($projects) && count($projects) > 0) {
    ?>
	<fieldset>
	<legend><?php 
    echo lang('parent workspace');
    ?>
</legend>
		<?php 
    // echo select_project('project[parent_id]', $projects, $project->isNew()?active_project()?active_project()->getId():0:$project->getParentId(), null, true)
    ?>
		<?php 
    if (!$project->isNew() && $project->getParentWorkspace() instanceof Project && !logged_user()->isProjectUser($project->getParentWorkspace())) {
        ?>
		<div class="tasksPanelWarning ico-warning32" style="font-size:10px;color:#666;background-repeat:no-repeat;padding-left:40px;max-width:600px;border:1px solid #E3AD00;background-color:#FFF690;background-position:4px 4px;">
			<div style="font-weight:bold;width:99%;text-align:center;padding:4px;color:#AF8300;"><?php 
        echo lang('cannot change parent workspace');
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:31,代码来源:add_project.php

示例7: copy

 /**
  * Copy project
  *
  * @param void
  * @return null
  */
 function copy()
 {
     trace(__FILE__, "copy():begin");
     if (!Project::canAdd(logged_user())) {
         flash_error(lang('no access permissions'));
         $this->redirectToReferer(get_url('dashboard'));
     }
     // if
     $this->setTemplate('copy_project');
     $this->setLayout('administration');
     $project_data = array_var($_POST, 'project');
     tpl_assign('project_data', $project_data);
     // Submitted...
     if (is_array($project_data)) {
         $source = Projects::findById($project_data['source']);
         if (!$source instanceof Project) {
             flash_error(lang('project dnx'));
             $this->redirectTo('administration', 'projects');
         }
         // if
         try {
             $shift_dates = isset($project_data['shift_dates']) ? $project_data['shift_dates'] == 'checked' : false;
             $copy_details = isset($project_data['copy_details']) ? $project_data['copy_details'] == 'checked' : false;
             $copy_tasks = isset($project_data['copy_tasks']) ? $project_data['copy_tasks'] == 'checked' : false;
             $copy_milestones = isset($project_data['copy_milestones']) ? $project_data['copy_milestones'] == 'checked' : false;
             $copy_messages = isset($project_data['copy_messages']) ? $project_data['copy_messages'] == 'checked' : false;
             $copy_links = isset($project_data['copy_links']) ? $project_data['copy_links'] == 'checked' : false;
             $copy_files = isset($project_data['copy_files']) ? $project_data['copy_files'] == 'checked' : false;
             $copy_users = isset($project_data['copy_users']) ? $project_data['copy_users'] == 'checked' : false;
             $copy_pages = isset($project_data['copy_pages']) ? $project_data['copy_pages'] == 'checked' : false;
             DB::beginWork();
             $project = new Project();
             $new_name = lang('projects copy new name', $source->getName());
             $new_name .= date(' z H:i:s');
             $project->setName($new_name);
             if ($copy_details) {
                 $project->setDescription($source->getDescription());
                 $project->setPriority($source->getPriority());
                 $project->setShowDescriptionInOverview($source->getShowDescriptionInOverview());
             }
             $project->save();
             $project_id = $project->getId();
             $add_seconds = 0;
             if (isset($project_data['add_days'])) {
                 $add_days = 0 + trim($project_data['add_days']);
                 $add_seconds = $add_days * 24 * 60 * 60;
             }
             $source_created_on = $source->getCreatedOn();
             //var_dump($source_created_on);
             $milestone_map = array(0 => 0);
             // project milestones
             if ($copy_milestones) {
                 $source_milestones = $source->getAllMilestones();
                 if (is_array($source_milestones)) {
                     foreach ($source_milestones as $source_milestone) {
                         $milestone = new ProjectMilestone();
                         //$milestone->copy($source_milestone);
                         $milestone->setName($source_milestone->getName());
                         $milestone->setDescription($source_milestone->getDescription());
                         if ($shift_dates) {
                             trace(__FILE__, "copy():shift dates");
                             $milestone->setDueDate(DateTimeValueLib::now());
                             $seconds = $source_milestone->getDueDate()->difference($source_created_on);
                             $milestone->getDueDate()->advance($seconds);
                         } else {
                             $milestone->setDueDate($source_milestone->getDueDate());
                         }
                         $milestone->getDueDate()->advance($add_seconds);
                         $milestone->setIsPrivate($source_milestone->getIsPrivate());
                         $milestone->setAssignedToUserId($source_milestone->getAssignedToUserId());
                         $milestone->setAssignedToCompanyId($source_milestone->getAssignedToCompanyId());
                         $milestone->setProjectId($project_id);
                         $milestone->save();
                         $milestone_map[$source_milestone->getId()] = $milestone->getId();
                     }
                     // foreach
                 }
                 // if
             }
             // if
             // project tasks
             if ($copy_tasks) {
                 $source_task_lists = $source->getAllTaskLists();
                 if (is_array($source_task_lists)) {
                     foreach ($source_task_lists as $source_task_list) {
                         $task_list = new ProjectTaskList();
                         //$task_list->copy($source_milestone);
                         $task_list->setName($source_task_list->getName());
                         $task_list->setPriority($source_task_list->getPriority());
                         $task_list->setDescription($source_task_list->getDescription());
                         if ($copy_milestones) {
                             $task_list->setMilestoneId($milestone_map[$source_task_list->getMilestoneId()]);
                         }
                         $task_list->setDueDate($source_task_list->getDueDate());
//.........这里部分代码省略.........
开发者ID:469306621,项目名称:Languages,代码行数:101,代码来源:ProjectController.class.php

示例8: add

 /**
  * Add project
  *
  * @param void
  * @return null
  */
 function add()
 {
     $this->setTemplate('add_project');
     $this->setLayout('administration');
     if (!Project::canAdd(logged_user())) {
         flash_error(lang('no access permissions'));
         $this->redirectToReferer(get_url('dashboard'));
     }
     // if
     $project = new Project();
     $project_data = array_var($_POST, 'project');
     tpl_assign('project', $project);
     tpl_assign('project_data', $project_data);
     // Submited...
     if (is_array($project_data)) {
         $project->setFromAttributes($project_data);
         $default_folders_config = str_replace(array("\r\n", "\r"), array("\n", "\n"), config_option('default_project_folders', ''));
         if (trim($default_folders_config) == '') {
             $default_folders = array();
         } else {
             $default_folders = explode("\n", $default_folders_config);
         }
         // if
         try {
             DB::beginWork();
             $project->save();
             $permissions = ProjectUsers::getPermissionColumns();
             $auto_assign_users = owner_company()->getAutoAssignUsers();
             // We are getting the list of auto assign users. If current user is not in the list
             // add it. He's creating the project after all...
             if (is_array($auto_assign_users)) {
                 $auto_assign_logged_user = false;
                 foreach ($auto_assign_users as $user) {
                     if ($user->getId() == logged_user()->getId()) {
                         $auto_assign_logged_user = true;
                     }
                 }
                 // if
                 if (!$auto_assign_logged_user) {
                     $auto_assign_users[] = logged_user();
                 }
             } else {
                 $auto_assign_users[] = logged_user();
             }
             // if
             foreach ($auto_assign_users as $user) {
                 $project_user = new ProjectUser();
                 $project_user->setProjectId($project->getId());
                 $project_user->setUserId($user->getId());
                 if (is_array($permissions)) {
                     foreach ($permissions as $permission) {
                         $project_user->setColumnValue($permission, true);
                     }
                 }
                 // if
                 $project_user->save();
             }
             // foreach
             if (count($default_folders)) {
                 $added_folders = array();
                 foreach ($default_folders as $default_folder) {
                     $folder_name = trim($default_folder);
                     if ($folder_name == '') {
                         continue;
                     }
                     // if
                     if (in_array($folder_name, $added_folders)) {
                         continue;
                     }
                     // if
                     $folder = new ProjectFolder();
                     $folder->setProjectId($project->getId());
                     $folder->setName($folder_name);
                     $folder->save();
                     $added_folders[] = $folder_name;
                 }
                 // foreach
             }
             // if
             ApplicationLogs::createLog($project, null, ApplicationLogs::ACTION_ADD, false, true);
             DB::commit();
             flash_success(lang('success add project', $project->getName()));
             $this->redirectToUrl($project->getPermissionsUrl());
         } catch (Exception $e) {
             tpl_assign('error', $e);
             DB::rollback();
         }
         // try
     }
     // if
 }
开发者ID:swenson,项目名称:projectpier,代码行数:97,代码来源:ProjectController.class.php


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