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


PHP Project::setAttributes方法代码示例

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


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

示例1: edit

 /**
  * Update project
  *
  * @param void
  * @return null
  */
 function edit()
 {
     $this->wireframe->print_button = false;
     if ($this->request->isApiCall() && !$this->request->isSubmitted()) {
         $this->httpError(HTTP_ERR_BAD_REQUEST, null, true, true);
     }
     // if
     if ($this->active_project->isNew()) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     if (!$this->active_project->canEdit($this->logged_user)) {
         $this->httpError(HTTP_ERR_FORBIDDEN);
     }
     // if
     $project_data = $this->request->post('project');
     if (!is_array($project_data)) {
         $project_data = array('name' => $this->active_project->getName(), 'overview' => $this->active_project->getOverview(), 'default_visibility' => $this->active_project->getDefaultVisibility(), 'leader_id' => $this->active_project->getLeaderId(), 'group_id' => $this->active_project->getGroupId(), 'company_id' => $this->active_project->getCompanyId(), 'default_visibility' => $this->active_project->getDefaultVisibility(), 'starts_on' => $this->active_project->getStartsOn());
     }
     // if
     $this->smarty->assign('project_data', $project_data);
     if ($this->request->isSubmitted()) {
         db_begin_work();
         $old_name = $this->active_project->getName();
         $this->active_project->setAttributes($project_data);
         if ($this->active_project->isModified('leader_id') && $this->active_project->getLeaderId()) {
             $leader = Users::findById($this->active_project->getLeaderId());
             if (instance_of($leader, 'User')) {
                 $this->active_project->setLeader($leader);
             }
             // if
         }
         // if
         if ($this->active_project->isModified('company_id')) {
             cache_remove('project_icons');
         }
         // if
         $save = $this->active_project->save();
         if ($save && !is_error($save)) {
             db_commit();
             if ($this->request->isApiCall()) {
                 $this->serveData($this->active_project, 'project');
             } else {
                 flash_success('Project :name has been updated', array('name' => $old_name));
                 $this->redirectToUrl($this->active_project->getOverviewUrl());
             }
             // if
         } else {
             db_rollback();
             if ($this->request->isApiCall()) {
                 $this->serveData($save);
             } else {
                 $this->smarty->assign('errors', $save);
             }
             // if
         }
         // if
     }
     // if
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:66,代码来源:ProjectController.class.php

示例2: testCRUD

 public function testCRUD()
 {
     //CREATE Test
     $newProject = new Project();
     $projectName = 'This is a Test';
     $newProject->setAttributes(array('name' => $projectName, 'description' => 'This project is for test purpose only', 'start_date' => '2010-11-15 15:00:00', 'end_date' => '2010-12-06 00:00:00', 'update_user_id' => 1, 'category' => 2, 'status' => 1, 'owner' => 1));
     $this->assertTrue($newProject->save(false));
     //READ Test
     $readProject = Project::model()->findByPk($newProject->id);
     $this->assertTrue($readProject instanceof Project);
     $this->assertEquals($projectName, $readProject->name);
     //UPDATE Test
     $updateProjectName = 'Updated Name2';
     $newProject->name = $updateProjectName;
     $this->AssertTrue($newProject->save(false));
     $updatedProject = Project::model()->findByPk($newProject->id);
     $this->assertTrue($updatedProject instanceof Project);
     $this->assertNotEquals($projectName, $updatedProject->name);
     //DELETE Test
     $deletedProjectId = $newProject->id;
     $newProject->delete();
     $deletedProject = Project::model()->findByPk($newProject->id);
     $this->assertEquals(Null, $deletedProject);
     //GetUserVote Test
     $project = Project::model()->findByPk(18);
     $this->assertTrue($project->getUserVote(7) == true);
     //Vote Test
     $this->assertTrue($project->vote(1, 1) == 1);
 }
开发者ID:rknox,项目名称:PPM-App,代码行数:29,代码来源:CRUDTest.php

示例3: testCreate

 public function testCreate()
 {
     // CREATE new project
     $newProject = new Project();
     $newProjectName = 'Test Project Creation';
     $newProject->setAttributes(array('name' => $newProjectName, 'description' => 'This is a test for new project creation'));
     Yii::app()->user->setId($this->users('user1')->id);
     // Save the new project, triggering attribute validation
     $this->assertTrue($newProject->save());
     // READ back the newly created project to ensure the creation worked
     $retrievedProject = Project::model()->findByPk($newProject->id);
     $this->assertTrue($retrievedProject instanceof Project);
     $this->assertEquals($newProjectName, $retrievedProject->name);
     $this->assertEquals(Yii::app()->user->id, $retrievedProject->create_user_id);
 }
开发者ID:nashant,项目名称:trackstar,代码行数:15,代码来源:ProjectTest.php

示例4: testCreate

 public function testCreate()
 {
     //Create new project
     $newProject = new Project();
     $newProjectName = 'Test Project 1';
     $newProject->setAttributes(array('name' => $newProjectName, 'description' => 'Unit test for project creation'));
     //Set user
     Yii::app()->user->setID($this->users('user1')->id);
     $this->assertTrue($newProject->save());
     //Read newly created project
     $retrievedProject = Project::model()->findByPk($newProject->id);
     $this->assertTrue($retrievedProject instanceof Project);
     $this->assertEquals($newProjectName, $retrievedProject->name);
     //Check user
     $this->assertEquals(Yii::app()->user->id, $retrievedProject->create_user_id);
 }
开发者ID:rossobrien,项目名称:trackstar,代码行数:16,代码来源:ProjectTest.php

示例5: testCreate

 public function testCreate()
 {
     //CREATE a new Project
     $newProject=new Project;
     $newProjectName = 'Test Project Creation';
     $newProject->setAttributes(array(
         'name' => $newProjectName,
         'description' => 'This is a test for new project creation',
         'createTime' => '2009-09-09 00:00:00',
         'createUser' => '1',
         'updateTime' => '2009-09-09 00:00:00',
         'updateUser' => '1',
         )
     );
     $this->assertTrue($newProject->save(false));
     
     //READ back the newly created Project to ensure the creation worked
     $retrievedProject=Project::model()->findByPk($newProject->id);
     $this->assertTrue($retrievedProject instanceof Project);
     $this->assertEquals($newProjectName,$retrievedProject->name);
 }
开发者ID:ratmir-kulakov,项目名称:yii,代码行数:21,代码来源:ProjectTest.php

示例6: actionAdmin

 /**
  * Manages all models.
  */
 public function actionAdmin()
 {
     $model = new Project('search');
     $model->unsetAttributes();
     // clear any default values
     if (isset($_GET['Project'])) {
         $model->setAttributes($_GET['Project']);
     }
     $this->render('admin', array('model' => $model));
 }
开发者ID:jessesiu,项目名称:GigaDBV3,代码行数:13,代码来源:AdminProjectController.php

示例7: save

 /**
  * 保存项目
  */
 public function save($data = array())
 {
     $oneProject = new Project();
     $data['user_id'] = Yii::app()->user->getId();
     $oneProject->setAttributes($data);
     $oneProject->save();
 }
开发者ID:bfyang5130,项目名称:zzl,代码行数:10,代码来源:ProjectForm.php


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