public function delete() { $p = Person::findFirst($this->getPersonId()); $s = Status::findFirst(array('name' => 'deleted')); $delete = $p->update(array('status_id' => $s->getId(), 'updated_at' => new \Datetime('now', new \DateTimeZone('UTC')))); return $delete ? true : false; }
/** * @param integer $statusId */ public function delete($statusId) { if (!$this->application->request->isDelete()) { throw new Exception('Method not allowed', 405); } if (!$this->isAllowed()) { throw new Exception('User not authorized', 401); } $status = Status::findFirst($statusId); if (!$status) { throw new Exception('Status not found', 404); } if (!$status->delete()) { throw new Exception('Status not deleted', 500); } return array('code' => 204, 'content' => 'Status instance deleted'); }
/** * @param text $statusName */ public function getList($statusName) { if (!$this->application->request->isGet()) { throw new Exception('Method not allowed', 405); } $statuses = Status::find(); $sArr = $statuses->toArray('name'); if (!in_array($st, $sArr)) { throw new Exception('Invalid parameter', 409); } $status = Status::findFirst(array('conditions' => "name = :name:", 'bind' => array('name' => $statusName))); $lyrics = Lyrics::find(array('conditions' => "status_id = :id:", 'bind' => array('id' => $status->getId()), 'order' => 'updated_at DESC')); if (!lyrics) { throw new Exception('Query not executed', 500); } if ($lyrics->count() == 0) { return array('code' => 204, 'content' => 'No lyrics instance found'); } return array('code' => 200, 'content' => $lyrics->toArray()); }
/** * @param integer $statusName */ public function getList($statusName) { if (!$this->application->request->isGet()) { throw new Exception('Method not allowed', 405); } $statuses = Status::find(); $statusesArr = $statuses->toArray('name'); if (!in_array($statusName, $statusesArr)) { throw new Exception('Invalid parameter', 409); } $status = Status::findFirst(array('conditions' => 'name = :name:', 'bind' => array('name' => $statusName))); $seasons = Season::find(array('conditions' => 'status_id = :id:', 'bind' => array('id' => $status->getId()), 'order' => 'number ASC', 'group' => 'program_id')); if (!$seasons) { throw new Exception('Query not executed', 500); } if ($seasons->count() == 0) { return array('code' => 204, 'content' => 'No matching Season instance found'); } return array('code' => 200, 'content' => $seasons->toArray()); }
public function add() { $user_model = new User(); $album_model = new Album(); $role_model = new Role(); $status_model = new Status(); $this->data['title'] = 'Add Artist'; if (isset($_POST) && !empty($_POST)) { $artistArray = array('user_firstname' => $_POST['firstname'], 'user_stagename' => $_POST['stagename'], 'user_bio' => $_POST['bio'], 'twitter_handle' => $_POST['twitter_handle'], 'user_status_id' => Status::id('active'), 'user_role_id' => Role::id('artist'), 'user_created' => time()); $artistArray = Gump::xss_clean($artistArray); $artistArray = Gump::sanitize($artistArray); $artist_id = $user_model->create($artistArray); if ($artist_id > 0) { $this->data['success'] = 'Artist Added!'; $slug = Url::generateSafeSlug($_POST['stagename'] . $artist_id); $user_model->updateId(array('user_slug' => $slug), $artist_id); } else { $this->data['error'] = 'Operation Fails!'; } //UPLOAD ATTACHMENT if ($_FILES["image"]["tmp_name"] != '') { //upload image into uploads folder Upload::setName($slug . uniqid()); Upload::resizeUpload($_FILES["image"], UPLOAD_PATH, '450px'); $update_data = array('user_image' => Upload::getFileName('images')); $this->user_model->updateId($update_data, $artist_id); } //GET INSERTED ID $this->data['user_data'] = $user_model->find($insert_id); Url::redirect('artist'); } View::rendertemplate('header', $this->data); View::rendertemplate('sidebar', $this->data); View::render('artist/artist.add', $this->data); View::rendertemplate('footer', $this->data); }
/** * @param text $statusName */ public function getList($statusName) { if (!$this->application->request->isGet()) { throw new Exception('Method not allowed', 405); } $statuses = Status::find(); $sArr = $statuses->toArray('name'); if (!in_array($statusName, $sArr)) { throw new Exception('Invalid parameter', 405); } $status = Status::findFirst(array('conditions' => "name = :name:", 'bind' => array('name' => $statusName))); $mangas = Manga::find(array('conditions' => "status_id = :id:", 'bind' => array('id' => $status->getId()), 'order' => 'name ASC')); if (!$mangas) { throw new Exception('Query not executed', 500); } if ($mangas->count() == 0) { return array('code' => 204, 'content' => 'No matching Manga instance found'); } $output = array(); foreach ($mangas as $m) { $mArr = $manga->toArray(); $mgNames = array(); foreach ($mArr['genres'] as $mg) { $mg = MangaGenre::findFirst($mg); array_push($mgNames, $mg->getName()); } $mArr['genres'] = $mgNames; array_push($output, $mArr); } return array('code' => 200, 'content' => $output); }
public function status($parameter) { $action = $parameter[0]; $id = $parameter[1]; $model = new \Models\Song(); if ($action == 'deactivate') { $update = $model->updateId(array('song_status_id' => Status::id('inactive')), $id); } else { if ($action == 'activate') { $update = $model->updateId(array('song_status_id' => Status::id('active')), $id); } } if ($update > 0) { Session::set('success', 'status edited!'); } else { Session::set('error', 'operation fails!'); } Url::previous(); }
public function signup($slug = null) { $this->data['title'] = 'Join Us'; $statusModel = new Status(); $roleModel = new Role(); $userModel = new User(); if (isset($_POST['email']) && !empty($_POST['email'])) { $firstname = $_POST['firstname']; $email = $_POST['email']; if ($_POST['password'] == $_POST['password2']) { $encrypted = md5($_POST['password']); $row_count = $userModel->getColRow('user_email', $email); if (!is_bool($row_count)) { Session::set('error', 'Email exists in our records, please use a different email'); } else { $userArray = array('user_firstname' => $firstname, 'user_email' => $email, 'user_password' => $encrypted, 'user_role_id' => Role::id('user'), 'user_status_id' => Status::id('active')); $userArray = Gump::xss_clean($userArray); $userArray = Gump::sanitize($userArray); $is_valid = Gump::is_valid($userArray, array('user_firstname' => 'required|max_len,200|min_len,1', 'user_email' => 'required|max_len,200|min_len,1', 'user_password' => 'required|max_len,200|min_len,1')); if ($is_valid === true) { $user_id = $userModel->create($userArray); if ($user_id > 0) { $slug = Url::generateSafeSlug($firstname . $user_id); //send email $subject = 'Welcome to GbeduMobile'; $content .= "You just opened a new account with us, Get login details below<br><br>"; $content .= "Username: "******"<br>"; $content .= "Password: "******"<br>"; if (ENVIRONMENT == 'production') { $mail = new Mail(); $mail->general($email, $subject, $firstname, $content); } Session::set('success', 'Login details has been sent to your email, Congrats!'); Url::redirect('home'); } else { Session::set('error', 'Operation Fails, Please contact admin'); } } else { Session::set('error', $is_valid); } } } else { Session::set('error', 'Password does not match!'); } } View::rendertemplate('header', $this->data); View::render('account/signup', $this->data); View::rendertemplate('footer', $this->data); }
/** * @param text $statusName */ public function getList($statusName) { if (!$this->application->request->isGet()) { throw new Exception('Method not allowed', 405); } $statuses = Status::find(); $statNames = $statuses->toArray('name'); if (!in_array($statuses, $statNames)) { throw new Exception('Invalid parameter', 409); } $status = Status::findFirst(array('conditions' => "name = :name:", 'bind' => array('name' => $statusName))); $MCs = MangaCharacter::find(array('conditions' => "status_id = :id:", 'bind' => array('id' => $status->getId()))); if (!$MCs) { throw new Exception('Query not executed', 500); } if ($MCs->count() == 0) { return array('code' => 204, 'content' => 'No matching MangaCharacter instance found'); } $output = array(); foreach ($MCs as $mc) { $p = Person::findFirst($mc->getPersonId()); $pArr = $p->toArray(); unset($pArr['id']); array_push($output, array_merge($mc->toArray(), $pArr)); } return array('code' => 200, 'content' => $output); }