public function setUp() { $this->event = $this->getMockBuilder('\\StateMachine\\EventInterface')->disableOriginalConstructor()->getMock(); $this->event->expects($this->any())->method('__toString')->willReturn('eventName'); $this->flag = $this->getMockBuilder('\\StateMachine\\Flag')->disableOriginalConstructor()->getMock(); $this->flag->expects($this->any())->method('__toString')->willReturn('flagName'); }
public function addFlag(Flag $flag) { if ($flag->getName()) { $this->flags[$flag->getName()] = $flag; } else { trigger_error('Flag must have a name'); } }
/** * @param $vars * @return array */ public function checkAssignVarsOk($vars) { $errors = array(); if (empty($vars['username'])) { $errors[] = 'AdminFlagsUsernameEmpty'; } else { // check if user name exists $member = new Member(); $member = $member->findByUsername($vars['username']); if (!$member) { $errors[] = 'AdminFlagsUsernameNotExisting'; } } if ($vars['flagid'] == 0) { $errors[] = 'AdminFlagsNoFlagSelected'; } else { // check if flag is already assigned if (isset($member)) { $flag = new Flag($vars['flagid']); $assigned = $flag->getFlagForMember($member); if ($assigned) { $errors[] = 'AdminFlagsAlreadyAssigned'; } } } if ($vars['level'] == 0) { $errors[] = 'AdminFlagsNoLevelSelected'; } if (empty($vars['comment'])) { $errors[] = 'AdminFlagsCommentEmpty'; } return $errors; }
/** * Change the active status of a flag on development * * @access public * @return void */ public function toggledevAction() { $id = $this->getRequest()->getParam('id'); $flagModel = new Flag(); $flagModel->toggleFlag($id, APP_STATE_DEVELOPMENT); App_FlagFlippers_Manager::save(); $this->_redirect('/flags/'); }
/** * Queries the Flag and Flipper and redirects the user to a different * page if he/her doesn't have the required permissions for * accessing the current page * * @access protected * @return void */ protected function _checkFlagFlippers() { $controllerName = Zend_Registry::get('controllerName'); $actionName = Zend_Registry::get('actionName'); $user = BaseUser::getSession(); if (Zend_Registry::get('IS_DEVELOPMENT') && $controllerName != 'error') { $flagModel = new Flag(); $flag = strtolower(CURRENT_MODULE) . '-' . $controllerName; if (!$flagModel->checkRegistered($flag, App_Inflector::camelCaseToDash($actionName))) { $params = array('originalController' => $controllerName, 'originalAction' => $actionName); $this->_forward('flagflippers', 'error', NULL, $params); return; } } //Check the flag and flippers for ZFDebug if (!App_FlagFlippers_Manager::isAllowed($user->group->name, 'testing', 'zfdebug')) { Zend_Controller_Front::getInstance()->unregisterPlugin('ZFDebug_Controller_Plugin_Debug'); } if (!App_FlagFlippers_Manager::isAllowed($user->group->name, $controllerName, $actionName)) { if (empty($user->id)) { // the user is a guest, save the request and redirect him to // the login page $session = new Zend_Session_Namespace('FrontendRequest'); $session->request = serialize($this->getRequest()); if (Zend_Controller_Front::getInstance()->getRequest()->getModuleName() == "frontend") { $this->_redirect($this->view->url(array('module' => 'frontend', 'controller' => 'user', 'action' => 'login'), 'default', true)); } else { $this->_redirect('/profile/login/'); } } else { $this->_redirect('/error/forbidden/'); } } }
public function getIndex() { $title = Lang::get('admin/hstokouts/title.hstokout_manajement'); // Title $hstokouts = $this->hstokout; // Grab all the blog hstokouts $jenisflags = ['' => ''] + Flag::lists('nama'); return View::make('admin.hstokouts.index', compact('hstokouts', 'title', 'jenisflags')); // Show the page }
/** * Overrides init() in Zend_Form * * @access public * @return void */ public function init() { // init the parent parent::init(); // set the form's method $this->setMethod('post'); $flagModel = new Flag(); $flagIdOptions = $flagModel->findPairs(); $name = new Zend_Form_Element_Text('name'); $name->setOptions(array('label' => 'Name', 'required' => TRUE, 'filters' => array('StringTrim', 'StripTags'), 'validators' => array('NotEmpty'))); $this->addElement($name); $flagId = new Zend_Form_Element_Select('flag_id'); $flagId->setOptions(array('label' => 'Flag', 'required' => TRUE, 'filters' => array('StringTrim', 'StripTags'), 'validators' => array('NotEmpty'), 'multiOptions' => $flagIdOptions)); $this->addElement($flagId); $description = new Zend_Form_Element_Text('description'); $description->setOptions(array('label' => 'Description', 'required' => TRUE, 'filters' => array('StringTrim', 'StripTags'), 'validators' => array('NotEmpty'))); $this->addElement($description); $id = new Zend_Form_Element_Hidden('id'); $id->setOptions(array('validators' => array(new Zend_Validate_Regex('/^\\d*$/')))); $this->addElement($id); $submit = new Zend_Form_Element_Submit('submit'); $submit->setOptions(array('label' => 'Save privilege', 'required' => TRUE)); $this->addElement($submit); }
public function addFlagInput($post) { $data = $this->record->getData($this->getPage()); $flag = new Flag(); $flag->link_id = $this->record->getID(); $flag->pages_name = $this->getPage(); foreach ($post as $key => $value) { $page = substr($key, 0, strpos($key, "-")); // Split out class and name from input field $fieldName = substr($key, strpos($key, "-") + 1); if ($page == 'flag') { $flag->set($fieldName, $value); } } if ($flag->isComplete()) { $data->delete($flag->getFieldName()); $flag->saveToDB(); $flag->getFromDB(); $flag->flag_id = $flag->getID(); } else { $flag = null; } return $flag; }
public function action_flaggedlistings() { if (Auth::check()) { if (Session::has('id')) { if (Session::get('admin') == 1) { $flags = Flag::all(); $listings = array(); foreach ($flags as $flag) { if (array_key_exists($flag->listing_id, $listings)) { $listings[$flag->listing_id]->flags += 1; } else { $listing = Listing::find($flag->listing_id); $listing->flags = 1; $listing->location = $listing->location()->first(); $listing->category = Categorie::find($listing->category_id)->title; $listings[$listing->id] = $listing; } } $view = View::make('account.flagged_listings.index')->with('title', 'Flagged Listings')->with('listings', $listings); return $view; } else { Redirect::to('/account/mylistings'); } } } }
public function action_unflag($id) { if (Auth::check() && Session::has('id')) { if (Session::get('admin') == 1) { $flags = Flag::all(); foreach ($flags as $flag) { if ($flag->listing_id == $id) { $flag->delete(); } } return Redirect::to('/account/flaggedListings'); } else { return Redirect::to('/'); } } else { return Redirect::to('/'); } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { Flag::destroy($id); flash()->success('The Flag has been deleted successfully'); }
/** * Delete a video * @param integer $video_id ID of video to be deleted * @return void Video is deleted from database and all related files and records are also deleted */ static function Delete($video_id) { App::LoadClass('Rating'); App::LoadClass('Flag'); App::LoadClass('Favorite'); App::LoadClass('Comment'); $db = Database::GetInstance(); $video = new self($video_id); Plugin::Trigger('video.delete'); // Delete files try { Filesystem::Open(); Filesystem::Delete(UPLOAD_PATH . '/flv/' . $video->filename . '.flv'); Filesystem::Delete(UPLOAD_PATH . '/thumbs/' . $video->filename . '.jpg'); Filesystem::Delete(UPLOAD_PATH . '/mobile/' . $video->filename . '.mp4'); Filesystem::Close(); } catch (Exception $e) { App::Alert('Error During Video Removal', "Unable to delete video files for: {$video->filename}. The video has been removed from the system, but the files still remain. Error: " . $e->getMessage()); } // Delete Comments $query = "SELECT comment_id FROM " . DB_PREFIX . "comments WHERE video_id = {$video_id}"; $result = $db->Query($query); while ($row = $db->FetchObj($result)) { Comment::Delete($row->comment_id); } // Delete Ratings $query = "SELECT rating_id FROM " . DB_PREFIX . "ratings WHERE video_id = {$video_id}"; $result = $db->Query($query); while ($row = $db->FetchObj($result)) { Rating::Delete($row->rating_id); } // Delete Favorites $query = "SELECT fav_id FROM " . DB_PREFIX . "favorites WHERE video_id = {$video_id}"; $result = $db->Query($query); while ($row = $db->FetchObj($result)) { Favorite::Delete($row->fav_id); } // Delete Flags $query = "SELECT flag_id FROM " . DB_PREFIX . "flags WHERE id = {$video_id} AND type = 'video'"; $result = $db->Query($query); while ($row = $db->FetchObj($result)) { Flag::Delete($row->flag_id); } // Delete Video $query = "DELETE FROM " . DB_PREFIX . "videos WHERE video_id = {$video_id}"; $db->Query($query); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function getDestroy($id) { return Flag::destroyFlag($id); }
public function testGetValue() { $flag = new Flag('flagName', 'flagValue'); $this->assertEquals('flagValue', $flag->getValue()); }
$message_type = 'success'; } break; case 'comment': $comment = new Comment($_GET['ban']); if ($comment->found) { Flag::FlagDecision($comment->comment_id, $type, true); $comment->Update(array('status' => 'banned')); $message = 'Comment has been banned'; $message_type = 'success'; } break; } } else { if (!empty($_GET['dismiss']) && is_numeric($_GET['dismiss'])) { Flag::FlagDecision($_GET['dismiss'], $type, false); $message = 'Flags has been dismissed'; $message_type = 'success'; } } ### Determine which type (account status) of members to display switch ($type) { case 'member': $query_string['status'] = 'member'; $header = 'Flagged Members'; $page_title = 'Flagged Members'; break; case 'video': $query_string['status'] = 'video'; $header = 'Flagged Videos'; $page_title = 'Flagged Videos';
/** * Generate the Acl object from the permission file * * @return Zend_Acl */ private static function _generateFromDb() { $aclObject = new Zend_Acl(); $aclObject->deny(); //Get all the models $backofficeUserModel = new BackofficeUser(); $groupModel = new Group(); $flagModel = new Flag(); $flipperModel = new Flipper(); $privilegeModel = new Privilege(); //Add all groups $groups = $groupModel->fetchAllThreaded(); foreach ($groups as $group) { if ($group->parent_name) { $aclObject->addRole(new Zend_Acl_Role($group->name), $group->parent_name); } else { $aclObject->addRole(new Zend_Acl_Role($group->name)); } } //Add all users $users = $backofficeUserModel->findAll(); foreach ($users as $user) { $aclObject->addRole(new Zend_Acl_Role($user->username), $user->groupNames); } //Add all resources $flags = $flagModel->fetchAll(); foreach ($flags as $flag) { $aclObject->addResource(new Zend_Acl_Resource($flag->name)); } //Add hardcoded resources $aclObject->addResource('frontend-error'); $aclObject->addResource('backoffice-error'); //Populate the ACLs $flippers = $flipperModel->fetchAll(); foreach ($flippers as $flipper) { switch (APPLICATION_ENV) { case APP_STATE_PRODUCTION: $flag = $flag->active_on_prod; break; default: $flag = $flag->active_on_dev; } $privilege = $flipper->findParentRow('Privilege'); $flipper->privilegeName = $privilege->name; $group = $flipper->findParentRow('Group'); $flipper->groupName = $group->name; $flag = $flipper->findParentRow('Flag'); $flipper->flagName = $flag->name; if (Zend_Registry::get('IS_PRODUCTION')) { $envAllowed = $flag->active_on_prod; } else { $envAllowed = $flag->active_on_dev; } if ($flipper->allow && $envAllowed) { $aclObject->allow($flipper->groupName, $flipper->flagName, $flipper->privilegeName); } else { $aclObject->deny($flipper->groupName, $flipper->flagName, $flipper->privilegeName); } } //Hardcode basic paths for members foreach (App_FlagFlippers_Manager::$_membersAllowedResources as $resource) { $aclObject->allow('members', $resource); } //Hardcode basic paths for guests foreach (App_FlagFlippers_Manager::$_guestsAllowedResources as $resource => $roles) { if (!is_array($roles)) { $aclObject->allow('guests', $resource); } else { foreach ($roles as $r) { $aclObject->allow('guests', $resource, $r); } } } //Everbody can see the errors $aclObject->allow(null, 'frontend-error'); $aclObject->allow(null, 'backoffice-error'); //Admins are allowed everywhere $aclObject->allow('administrators'); return $aclObject; }
// Validate status if (!empty($_POST['status']) && !ctype_space($_POST['status'])) { $data['status'] = htmlspecialchars(trim($_POST['status'])); } else { $errors['status'] = 'Invalid status'; } // Update video if no errors were made if (empty($errors)) { // Perform addional actions based on status change if ($data['status'] != $video->status) { // Handle "Approve" action if ($data['status'] == 'approved') { $video->Approve('approve'); } else { if ($data['status'] == 'banned') { Flag::FlagDecision($video->video_id, 'video', true); } } } $video->Update($data); $message = 'Video has been updated.'; $message_type = 'success'; } else { $message = 'The following errors were found. Please correct them and try again.'; $message .= '<br /><br /> - ' . implode('<br /> - ', $errors); $message_type = 'error'; } } // Output Header include 'header.php'; ?>
} ### Update User if no errors were found if (empty($errors)) { // Perform addional actions based on status change if ($data['status'] != $user->status) { switch ($data['status']) { // Handle "Approve" action case 'active': $user->UpdateContentStatus('active'); $user->Approve('approve'); break; // Handle "Ban" action // Handle "Ban" action case 'banned': $user->UpdateContentStatus('banned'); Flag::FlagDecision($user->user_id, 'user', true); break; // Handle "Pending" or "New" action // Handle "Pending" or "New" action case 'new': case 'pending': $user->UpdateContentStatus($data['status']); break; } } if (isset($data['password'])) { $data['password'] = md5($data['password']); } $message = 'Member has been updated.'; $message_type = 'success'; $user->Update($data);
/** * Delete a record * @param integer $id ID of record to be deleted * @return void Record is deleted from database */ static function Delete($id) { App::LoadClass('Privacy'); App::LoadClass('Avatar'); App::LoadClass('Video'); App::LoadClass('Subscription'); App::LoadClass('Rating'); App::LoadClass('Flag'); App::LoadClass('Favorite'); App::LoadClass('Comment'); App::LoadClass('Post'); App::LoadClass('Message'); $db = Database::GetInstance(); $user = new self($id); Plugin::Trigger('user.delete'); // Delete Avatar if (!empty($user->avatar)) { Avatar::Delete($user->avatar); } // Delete Privacy Record $privacy_id = Privacy::Exist(array('user_id' => $id)); Privacy::Delete($privacy_id); // Delete Comments $query = "SELECT comment_id FROM " . DB_PREFIX . "comments WHERE user_id = {$id}"; $result = $db->Query($query); while ($row = $db->FetchObj($result)) { Comment::Delete($row->comment_id); } // Delete Ratings $query = "SELECT rating_id FROM " . DB_PREFIX . "ratings WHERE user_id = {$id}"; $result = $db->Query($query); while ($row = $db->FetchObj($result)) { Rating::Delete($row->rating_id); } // Delete Favorites $query = "SELECT fav_id FROM " . DB_PREFIX . "favorites WHERE user_id = {$id}"; $result = $db->Query($query); while ($row = $db->FetchObj($result)) { Favorite::Delete($row->fav_id); } // Delete Flags $query = "SELECT flag_id FROM " . DB_PREFIX . "flags WHERE id = {$id} AND type = 'user'"; $result = $db->Query($query); while ($row = $db->FetchObj($result)) { Flag::Delete($row->flag_id); } // Delete Subscriptions $query = "SELECT sub_id FROM " . DB_PREFIX . "subscriptions WHERE user_id = {$id} OR member = {$id}"; $result = $db->Query($query); while ($row = $db->FetchObj($result)) { Subscription::Delete($row->sub_id); } // Delete Posts $query = "SELECT post_id FROM " . DB_PREFIX . "posts WHERE user_id = {$id}"; $result = $db->Query($query); while ($row = $db->FetchObj($result)) { Post::Delete($row->post_id); } // Delete Messages $query = "SELECT message_id FROM " . DB_PREFIX . "messages WHERE user_id = {$id} OR recipient = {$id}"; $result = $db->Query($query); while ($row = $db->FetchObj($result)) { Message::Delete($row->message_id); } // Delete Videos $query = "SELECT video_id FROM " . DB_PREFIX . "videos WHERE user_id = {$id}"; $result = $db->Query($query); while ($row = $db->FetchObj($result)) { Video::Delete($row->video_id); } // Delete Privacy $query = "SELECT privacy_id FROM " . DB_PREFIX . "privacy WHERE user_id = {$id}"; $result = $db->Query($query); while ($row = $db->FetchObj($result)) { Privacy::Delete($row->privacy_id); } // Delete User $query = "DELETE FROM " . DB_PREFIX . self::$table . " WHERE " . self::$id_name . " = {$id}"; $db->Query($query); }
if ($trial->checkPageLogin($page)) { // Check that the user has the privilege to access this page switch ($_POST['request']) { case 'addFlag': $flag = $trial->addFlagInput($_POST); // Add form input to create a new flag if ($flag) { // If a new flag was produced, return it echo json_encode(array("message" => "Flag successfully added", "flag" => $flag)); } else { // Otherwise throw an error throw new Exception("Flag form not completely filled in, please try again."); } break; case 'clearFlag': $flag = new Flag($_POST['flag_id']); // Retrieve flag from DB and delete it $flag->deleteFromDB(); echo json_encode(array("message" => "Flag cleared")); break; case 'getFlags': // Select $sql = "SELECT field, id AS flag_id FROM flag \n WHERE pages_name = ? AND link_id = ?"; $id = $trial->user->isLinked(); $pA = array('si', $page, $id); $flagArr = array(); $result = DB::query($sql, $pA); foreach ($result->rows as $row) { $flagArr[$row->field] = new Flag($row->flag_id); } echo json_encode($flagArr);
throw new Exception(Language::GetText('error_flag_own')); } // Verify Flag doesn't exist $data = array('type' => $_POST['type'], 'id' => $_POST['id'], 'user_id' => $user->user_id); if (Flag::Exist($data)) { throw new Exception(Language::GetText('error_flag_duplicate')); } Plugin::Trigger('flag.ajax.before_flag'); // Send admin alert if (Settings::Get('alerts_flags') == '1') { $subject = 'Content Flagged As Inappropriate'; $body = "One of your members flagged content as inappropriate. "; $body .= "Please review the content to verify it is valid. "; $body .= "You can login to the Admin Panel to dismiss the flag, or uphold it and ban the content."; $body .= "\n\n=======================================================\n"; $body .= "Content Type: {$type}\n"; $body .= "URL: {$url}\n"; $body .= "{$name}\n"; $body .= "======================================================="; Plugin::Trigger('flag.ajax.alert'); App::Alert($subject, $body); } // Create flag and output message Flag::Create($data); Plugin::Trigger('flag.ajax.flag'); echo json_encode(array('result' => 1, 'msg' => (string) Language::GetText('success_flag'))); exit; } catch (Exception $e) { echo json_encode(array('result' => 0, 'msg' => $e->getMessage())); exit; }
} else { if (!empty($_GET['unban']) && is_numeric($_GET['unban'])) { // Validate id $comment = new Comment($_GET['unban']); if ($comment->found) { $comment->Approve('approve'); $message = 'Comment has been unbanned'; $message_type = 'success'; } } else { if (!empty($_GET['ban']) && is_numeric($_GET['ban'])) { // Validate id $comment = new Comment($_GET['ban']); if ($comment->found) { $comment->Update(array('status' => 'banned')); Flag::FlagDecision($comment->comment_id, 'comment', true); $message = 'Comment has been banned'; $message_type = 'success'; } } } } } ### Determine which type (status) of record to display $status = !empty($_GET['status']) ? $_GET['status'] : 'approved'; switch ($status) { case 'pending': $query_string['status'] = 'pending'; $header = 'Pending Comments'; $page_title = 'Pending Comments'; break;
/** * Test the is bool function */ public function testIsBool() { $this->assertFalse($this->object->isBool()); $this->object = new Flag('-f', '', true); $this->assertTrue($this->object->isBool()); }
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <link rel="stylesheet" href="/media/css/animations.css"> <link rel="stylesheet" href="/media/css/bootstrap-material-design.css"> <link rel="stylesheet" href="/media/css/ripples.css"> <link href="/media/css/ultimate_flash_map_killer.css" rel="stylesheet" type="text/css"/> <link rel="stylesheet" type="text/css" href="/media/css/slick.css"/> <link rel="stylesheet" type="text/css" href="/media/css/slick-theme.css"/> <link rel="stylesheet" type="text/css" href="/media/css/magnific-popup.css"/> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js" type="text/javascript"></script> <script src="https://yastatic.net/bootstrap/3.3.4/js/bootstrap.min.js" type="text/javascript"></script> <?php $flag = new Flag($title); if ($flag->Ico()) { $favicon = $flag->Ico(); } else { $favicon = "/favicon.ico"; } ?> <link rel="shortcut icon" href="<?php echo $favicon; ?> " type="image/x-icon"/> <link rel="icon" href="<?php echo $favicon; ?> " type="image/x-icon"/>
public function remove() { $this->checkRights('Flags'); $flagId = $this->route_vars['id']; $username = $this->route_vars['username']; // Check if flag and user exist and if flag is assigned to user at all; redirect if not $flag = new Flag($flagId); if (!$flag) { $this->redirectAbsolute($this->router->url('admin_flags_overview')); } $temp = new Member(); $member = $temp->findByUsername($username); if (!$member) { $this->redirectAbsolute($this->router->url('admin_flags_overview')); } $assigned = $flag->getFlagForMember($member); if (!$assigned) { $this->redirectAbsolute($this->router->url('admin_flags_overview')); } $page = new AdminFlagsRemovePage(); $flags = $this->model->getFlags(true); $page->flags = $flags; $redirectTo = ''; if (isset($_SERVER['HTTP_REFERER'])) { if (strpos($_SERVER['HTTP_REFERER'], "/list/members") !== false) { $redirectTo = 'members'; } if (strpos($_SERVER['HTTP_REFERER'], "/list/member/") !== false) { $redirectTo = 'member'; } if (strpos($_SERVER['HTTP_REFERER'], "/list/Flags") !== false) { $redirectTo = 'Flags'; } if (strpos($_SERVER['HTTP_REFERER'], "/list/flag/") !== false) { $redirectTo = 'flag'; } } $vars = array('username' => $username, 'flag' => $flagId, 'level' => $assigned->Level, 'scope' => $assigned->Scope, 'comment' => $assigned->Comment, 'redirect' => $redirectTo); $page->vars = $vars; return $page; }
public function run() { Flag::create(['icon' => 'fa fa-check', 'type' => 'success', 'message' => 'All OK!']); Flag::create(['icon' => 'fa fa-spinner fa-spin', 'type' => 'info', 'message' => 'Server is currently restarting!']); Flag::create(['icon' => 'fa-cloud-download', 'type' => 'info', 'message' => 'Server is currently updating!']); Flag::create(['icon' => 'fa fa-exclamation-triangle', 'type' => 'warning', 'message' => 'The current RCON password is incorrect for this server!']); Flag::create(['icon' => 'fa fa-eye', 'type' => 'warning', 'message' => 'Failed to connect to server on latest refresh - server may be changing maps!']); Flag::create(['icon' => 'fa fa-exclamation', 'type' => 'error', 'message' => 'Server down - the retries count has been breached!']); }
public function getIndex() { $title = Lang::get('admin/tgudangs/title.tgudang_manajement'); $tgudangs = $this->tgudang; // Ambil semua tgudangs $jenisflags = ['' => ''] + Flag::lists('nama'); return View::make('admin.tgudangs.index', compact('tgudangs', 'title', 'jenisflags')); }