Ejemplo n.º 1
0
 public function action()
 {
     $this->db()->transaction();
     $updateResult = \Model\User::update();
     if ($updateResult['status'] == false) {
         $this->db()->rollBack();
         $this->error($updateResult['mes']);
     }
     $this->db()->commit();
     $this->success($GLOBALS['_LANG']['USER']['UPDATE_USER_SUCCESS'], $this->url('Team-User-index'));
 }
Ejemplo n.º 2
0
 public function testUpdate()
 {
     $u = new User($this->container);
     $this->assertNotFalse($u->create(array('username' => 'toto', 'password' => '123456', 'name' => 'Toto')));
     $this->assertTrue($u->update(array('id' => 2, 'username' => 'biloute')));
     $user = $u->getById(2);
     $this->assertNotFalse($user);
     $this->assertTrue(is_array($user));
     $this->assertEquals('biloute', $user['username']);
     $this->assertEquals('Toto', $user['name']);
     $this->assertEquals(0, $user['is_admin']);
     $this->assertEquals(0, $user['is_ldap_user']);
 }
Ejemplo n.º 3
0
 public function testSendWithEmailAddress()
 {
     $en = new EmailNotification($this->container);
     $p = new Project($this->container);
     $tf = new TaskFinder($this->container);
     $tc = new TaskCreation($this->container);
     $u = new User($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'test')));
     $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1)));
     $this->assertTrue($u->update(array('id' => 1, 'email' => 'test@localhost')));
     $this->container['emailClient'] = $this->getMockBuilder('\\Core\\EmailClient')->setConstructorArgs(array($this->container))->setMethods(array('send'))->getMock();
     $this->container['emailClient']->expects($this->once())->method('send')->with($this->equalTo('test@localhost'), $this->equalTo('admin'), $this->equalTo('[test][New task] test (#1)'), $this->stringContains('test'));
     $en->send($u->getById(1), Task::EVENT_CREATE, array('task' => $tf->getDetails(1)));
 }
Ejemplo n.º 4
0
 public function testTaskClose()
 {
     $action = new Action\TaskEmail($this->container, 1, Task::EVENT_CLOSE);
     $action->setParam('column_id', 2);
     $action->setParam('user_id', 1);
     $action->setParam('subject', 'My email subject');
     // We create a task in the first column
     $tc = new TaskCreation($this->container);
     $tf = new TaskFinder($this->container);
     $p = new Project($this->container);
     $u = new User($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'test')));
     $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1, 'column_id' => 1)));
     $this->assertTrue($u->update(array('id' => 1, 'email' => 'admin@localhost')));
     // We create an event
     $event = array('project_id' => 1, 'task_id' => 1, 'column_id' => 2);
     // Email should be sent
     $this->container['emailClient']->expects($this->once())->method('send')->with($this->equalTo('admin@localhost'), $this->equalTo('admin'), $this->equalTo('My email subject'), $this->stringContains('test'));
     // Our event should be executed
     $this->assertTrue($action->execute(new GenericEvent($event)));
 }
 public function testIcalEventsWithAssigneeAndDueDate()
 {
     $dp = new DateParser($this->container);
     $p = new Project($this->container);
     $tc = new TaskCreation($this->container);
     $tf = new TaskFilterICalendarFormatter($this->container);
     $u = new User($this->container);
     $c = new Config($this->container);
     $this->assertNotFalse($c->save(array('application_url' => 'http://kb/')));
     $this->assertEquals('http://kb/', $c->get('application_url'));
     $this->assertNotFalse($u->update(array('id' => 1, 'email' => 'bob@localhost')));
     $this->assertEquals(1, $p->create(array('name' => 'test')));
     $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'task1', 'owner_id' => 1, 'date_due' => $dp->getTimestampFromIsoFormat('+5 days'))));
     $ics = $tf->create()->filterByDueDateRange(strtotime('-1 month'), strtotime('+1 month'))->setFullDay()->setCalendar(new Calendar('Kanboard'))->setColumns('date_due')->addFullDayEvents()->format();
     $this->assertContains('UID:task-#1-date_due', $ics);
     $this->assertContains('DTSTART;TZID=UTC;VALUE=DATE:' . date('Ymd', strtotime('+5 days')), $ics);
     $this->assertContains('DTEND;TZID=UTC;VALUE=DATE:' . date('Ymd', strtotime('+5 days')), $ics);
     $this->assertContains('URL:http://kb/?controller=task&action=show&task_id=1&project_id=1', $ics);
     $this->assertContains('SUMMARY:#1 task1', $ics);
     $this->assertContains('ORGANIZER;CN=admin:MAILTO:bob@localhost', $ics);
     $this->assertContains('X-MICROSOFT-CDO-ALLDAYEVENT:TRUE', $ics);
 }
Ejemplo n.º 6
0
 /**
  * Update the user table based on the Google profile information
  *
  * @access public
  * @param  integer   $user_id    User id
  * @param  array     $profile    Google profile
  * @return boolean
  */
 public function updateUser($user_id, array $profile)
 {
     $userModel = new User($this->db, $this->event);
     return $userModel->update(array('id' => $user_id, 'google_id' => $profile['id'], 'email' => $profile['email'], 'name' => $profile['name']));
 }
Ejemplo n.º 7
0
/**
 * User procedures
 */
$server->register('createUser', function (array $values) use($user) {
    list($valid, ) = $user->validateCreation($values);
    return $valid && $user->create($values);
});
$server->register('getUser', function ($user_id) use($user) {
    return $user->getById($user_id);
});
$server->register('getAllUsers', function () use($user) {
    return $user->getAll();
});
$server->register('updateUser', function ($values) use($user) {
    list($valid, ) = $user->validateModification($values);
    return $valid && $user->update($values);
});
$server->register('removeUser', function ($user_id) use($user) {
    return $user->remove($user_id);
});
/**
 * Category procedures
 */
$server->register('createCategory', function ($project_id, $name) use($category) {
    $values = array('project_id' => $project_id, 'name' => $name);
    list($valid, ) = $category->validateCreation($values);
    return $valid && $category->create($values);
});
$server->register('getCategory', function ($category_id) use($category) {
    return $category->getById($category_id);
});
Ejemplo n.º 8
0
        //密码为空,那么不对该数据进行编辑
        if ($data['user_pass'] == '') {
            unset($data['user_pass']);
        }
        //去除未更新数据.
        foreach ($data as $k => $v) {
            if ($user[$k] == $v) {
                unset($data[$k]);
            }
        }
        unset($user);
        //没有需要进行更新的数据
        if (count($data) < 1) {
            Response::json(array('msg' => '数据未更改,不需要进行更新'), 1);
        }
        User::update($data, $eid);
    } else {
        User::insert($data);
    }
    Response::json(array('msg' => '操作成功'), 0);
}
$formData = array();
if ($eid != '') {
    $formData = User::getUserDataById($eid);
    $formData['user_age'] = $formData['user_age'] == 0 ? '' : $formData['user_age'];
    $formData['user_qq'] = $formData['user_qq'] == 0 ? '' : $formData['user_qq'];
    $formData['user_phone'] = $formData['user_phone'] == 0 ? '' : $formData['user_phone'];
    $formData['user_mobile'] = $formData['user_mobile'] == 0 ? '' : $formData['user_mobile'];
} else {
    $formData = User::getTableAttribute();
}
Ejemplo n.º 9
0
 public function testSendNotifications()
 {
     $u = new User($this->container);
     $n = new Notification($this->container);
     $p = new Project($this->container);
     $tc = new TaskCreation($this->container);
     $tf = new TaskFinder($this->container);
     $pp = new ProjectPermission($this->container);
     $this->assertEquals(1, $p->create(array('name' => 'UnitTest1', 'is_everybody_allowed' => 1)));
     $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1)));
     $this->assertTrue($u->update(array('id' => 1, 'email' => 'test@localhost')));
     $this->assertTrue($pp->isEverybodyAllowed(1));
     $n->saveSettings(1, array('notifications_enabled' => 1, 'notifications_filter' => NotificationFilter::FILTER_NONE, 'notification_types' => array(NotificationType::TYPE_WEB => 1, NotificationType::TYPE_EMAIL => 1)));
     $this->container['emailNotification'] = $this->getMockBuilder('\\Model\\EmailNotification')->setConstructorArgs(array($this->container))->setMethods(array('send'))->getMock();
     $this->container['webNotification'] = $this->getMockBuilder('\\Model\\WebNotification')->setConstructorArgs(array($this->container))->setMethods(array('send'))->getMock();
     $this->container['emailNotification']->expects($this->once())->method('send');
     $this->container['webNotification']->expects($this->once())->method('send');
     $n->sendNotifications(Task::EVENT_CREATE, array('task' => $tf->getDetails(1)));
 }