本文整理汇总了PHP中flash_error函数的典型用法代码示例。如果您正苦于以下问题:PHP flash_error函数的具体用法?PHP flash_error怎么用?PHP flash_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了flash_error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: closeAutoCheckedoutFilesByUser
/**
* Return all project files that were automatically checked out (on edit) by the user
*
* @param User $user
* @return array
*/
static function closeAutoCheckedoutFilesByUser($user = null)
{
if (!$user) {
$user = logged_user();
}
try {
$condstr = 'checked_out_by_id = ' . $user->getId() . ' AND was_auto_checked_out = 1 AND checked_out_on <> \'' . EMPTY_DATETIME . '\'';
$files = self::findAll(array('conditions' => $condstr));
// findAll
if ($files) {
foreach ($files as $file) {
$file->setWasAutoCheckedAuto($autoCheckOut);
$file->setCheckedOutById(0);
$file->setCheckedOutOn(EMPTY_DATETIME);
$file->setMarkTimestamps(false);
$file->save();
}
return true;
}
return false;
} catch (Exception $exc) {
flash_error(lang('error checkin file'));
return false;
}
}
示例2: add
function add()
{
$pt = DB::escape(array_var($_GET, 'pt'));
$t = DB::escape(array_var($_GET, 't'));
$dep = ProjectTaskDependencies::findOne(array('conditions' => "`previous_task_id` = {$pt} AND `task_id` = {$t}"));
if (!$dep instanceof ProjectTaskDependency) {
try {
DB::beginWork();
$dep = new ProjectTaskDependency();
$dep->setPreviousTaskId(array_var($_GET, 'pt'));
$dep->setTaskId(array_var($_GET, 't'));
$dep->save();
DB::commit();
} catch (Exception $e) {
flash_error($e->getMessage());
DB::rollback();
}
}
flash_success(lang('success add task dependency'));
$reload = array_var($_GET, 'reload', true);
if ($reload) {
ajx_current("reload");
} else {
ajx_current("empty");
}
}
示例3: update_category
/**
* Show and process config category form
*
* @param void
* @return null
*/
function update_category()
{
$category = ConfigCategories::findById(get_id());
if (!$category instanceof ConfigCategory) {
flash_error(lang('config category dnx'));
$this->redirectToReferer(get_url('administration'));
}
// if
if ($category->isEmpty()) {
flash_error(lang('config category is empty'));
$this->redirectToReferer(get_url('administration'));
}
// if
$options = $category->getOptions(false);
$categories = ConfigCategories::getAll(false);
tpl_assign('category', $category);
tpl_assign('options', $options);
tpl_assign('config_categories', $categories);
$submitted_values = array_var($_POST, 'options');
if (is_array($submitted_values)) {
foreach ($options as $option) {
$new_value = array_var($submitted_values, $option->getName());
if (is_null($new_value) || $new_value == $option->getValue()) {
continue;
}
$option->setValue($new_value);
$option->save();
}
// foreach
flash_success(lang('success update config category', $category->getDisplayName()));
$this->redirectTo('administration', 'configuration');
}
// if
$this->setSidebar(get_template_path('update_category_sidebar', 'config'));
}
示例4: canGoOn
/**
* Determine if a user canGoOn to deny access to files in projects
* to which the user has not been assigned.
*
* @access public
* @return null
*/
function canGoOn()
{
if (active_project() == null || !logged_user()->isProjectUser(active_project())) {
flash_error(lang('no access permissions'));
$this->redirectTo('dashboard');
}
// if
}
示例5: login
/**
* Log user in
*
* @param void
* @return null
*/
function login()
{
$redirect_to = null;
// Get page user wanted to visit based on GET params
if ($this->request->get('re_route')) {
$params = array();
foreach ($this->request->url_params as $k => $v) {
if ($k != 're_route' && str_starts_with($k, 're_')) {
$params[substr($k, 3)] = $v;
}
// if
}
// if
$redirect_to = assemble_url($this->request->get('re_route'), $params);
} else {
$redirect_to = assemble_url('dashboard');
}
// if
// If user is already logged in redirect him to page he wanted to visit
if (instance_of($this->logged_user, 'User')) {
flash_error('You are already logged in as :display. Please logout before you can login on another account', array('display' => $this->logged_user->getDisplayName()));
$this->redirectToUrl($redirect_to);
}
// if
$login_data = $this->request->post('login');
$this->smarty->assign(array('login_data' => $login_data, 'auto_focus' => true));
if ($this->request->isSubmitted()) {
$errors = new ValidationErrors();
$email = trim(array_var($login_data, 'email'));
$password = array_var($login_data, 'password');
$remember = (bool) array_var($login_data, 'remember');
if ($email == '') {
$errors->addError(lang('Email address is required'), 'email');
}
// if
if (trim($password) == '') {
$errors->addError(lang('Password is required'), 'password');
}
// if
if ($errors->hasErrors()) {
$this->smarty->assign('auto_focus', false);
$this->smarty->assign('errors', $errors);
$this->render();
}
// if
$user =& $this->authentication->provider->authenticate(array('email' => $email, 'password' => $password, 'remember' => $remember));
if (!$user || is_error($user)) {
$errors->addError(lang('Failed to log you in with data you provided. Please try again'), 'login');
$this->smarty->assign('errors', $errors);
$this->render();
}
// if
flash_success(lang('Welcome back :display!', array('display' => $user->getDisplayName()), true, $user->getLanguage()), null, true);
$this->redirectToUrl($redirect_to);
}
// if
}
示例6: delete_state
function delete_state()
{
$this->setTemplate(get_template_path('back'));
ajx_current("empty");
try {
$query = "DELETE FROM `" . TABLE_PREFIX . "guistate` WHERE `contact_id` = " . DB::escape(logged_user()->getId());
DB::executeAll($query);
flash_success(lang("success reset gui state"));
} catch (Exception $e) {
flash_error($e->getMessage());
}
}
示例7: project_tag
/**
* Show project objects tagged with specific tag
*
* @access public
* @param void
* @return null
*/
function project_tag()
{
$tag = array_var($_GET, 'tag');
if (trim($tag) == '') {
flash_error(lang('tag dnx'));
$this->redirectTo('project', 'tags');
}
// if
$tagged_objects = active_project()->getObjectsByTag($tag);
$total_tagged_objects = 0;
if (is_array($tagged_objects)) {
foreach ($tagged_objects as $type => $objects) {
if (is_array($objects)) {
$total_tagged_objects += count($objects);
}
}
// foreach
}
// if
tpl_assign('tag', $tag);
tpl_assign('tagged_objects', $tagged_objects);
tpl_assign('total_tagged_objects', $total_tagged_objects);
}
示例8: add_attachment
/**
* Attach object to specific page and redirects to specified page
*
* @access public
* @param void
* @return null
*/
function add_attachment()
{
$project = active_project();
if (!$project instanceof Project) {
flash_error(lang('project dnx'));
$this->redirectToReferer(get_url('dashboard'));
}
// if
if (!$project->canEdit(logged_user())) {
flash_error(lang('no access permissions'));
$this->redirectToReferer(get_url('dashboard'));
}
// if
$page_attachment = new PageAttachment();
$page_attachment->setText(lang('description'));
$page_attachment->setRelObjectId('0');
$page_attachment->setRelObjectManager(array_var($_GET, 'rel_object_manager'));
$page_attachment->setProjectId($project->getId());
$page_attachment->setPageName(array_var($_GET, 'page_name'));
$page_attachment->setOrder(array_var($_GET, 'order'));
$page_attachment->save();
PageAttachments::reorder(array_var($_GET, 'page_name'), $project);
$this->redirectToReferer(get_url('dashboard'));
}
示例9: view
function view()
{
$comment = Comments::findById(get_id());
if (!$comment instanceof Comment) {
flash_error(lang('comment dnx'));
ajx_current("empty");
return;
}
if (!$comment->canView(logged_user())) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
$object = $comment->getRelObject();
if (!$object instanceof ContentDataObject) {
flash_error(lang('object dnx'));
ajx_current("empty");
return;
}
redirect_to($object->getViewUrl());
}
示例10: permissions
/**
* Show permission update form
*
* @param void
* @return null
*/
function permissions()
{
if (!active_project()->canChangePermissions(logged_user())) {
flash_error(lang('no access permissions'));
$this->redirectToUrl(active_project()->getOverviewUrl());
}
// if
$project_init = array_var($_GET, 'project_init');
tpl_assign('project_init', $project_init);
tpl_assign('project_users', active_project()->getUsers(false));
tpl_assign('project_companies', active_project()->getCompanies());
tpl_assign('user_projects', logged_user()->getProjects());
$permissions = PermissionManager::getPermissionsText();
tpl_assign('permissions', $permissions);
$companies = array(owner_company());
$clients = owner_company()->getClientCompanies();
if (is_array($clients)) {
$companies = array_merge($companies, $clients);
}
// if
tpl_assign('companies', $companies);
if (array_var($_POST, 'process') == 'process') {
try {
DB::beginWork();
active_project()->clearCompanies();
active_project()->clearUsers();
$companies = array(owner_company());
$client_companies = owner_company()->getClientCompanies();
if (is_array($client_companies)) {
$companies = array_merge($companies, $client_companies);
}
// if
foreach ($companies as $company) {
// Company is selected!
if (array_var($_POST, 'project_company_' . $company->getId()) == 'checked') {
// Owner company is automaticly included so it does not need to be in project_companies table
if (!$company->isOwner()) {
$project_company = new ProjectCompany();
$project_company->setProjectId(active_project()->getId());
$project_company->setCompanyId($company->getId());
$project_company->save();
}
// if
$users = $company->getUsers();
if (is_array($users)) {
$counter = 0;
foreach ($users as $user) {
$user_id = $user->getId();
$counter++;
if (array_var($_POST, "project_user_{$user_id}") == 'checked') {
$project_user = new ProjectUser();
$project_user->setProjectId(active_project()->getId());
$project_user->setUserId($user_id);
foreach ($permissions as $permission => $permission_text) {
// Owner company members have all permissions
$permission_value = $company->isOwner() ? true : array_var($_POST, 'project_user_' . $user_id . '_' . $permission) == 'checked';
$setter = 'set' . Inflector::camelize($permission);
$project_user->{$setter}($permission_value);
}
// if
$project_user->save();
}
// if
}
// foreach
}
// if
}
// if
}
// foreach
DB::commit();
flash_success(lang('success update project permissions'));
if ($project_init) {
$this->redirectToUrl(active_project()->getEditUrl(active_project()->getOverviewUrl()));
} else {
$this->redirectTo('project_settings', 'users');
}
// if
} catch (Exception $e) {
DB::rollback();
flash_error(lang('error update project permissions'));
$this->redirectTo('project_settings', 'permissions');
}
// try
}
// if
}
示例11: quick_add
/**
* @author Ignacio Vazquez <elpepe.uy at gmail dot com>
* Handle quick add submit
*/
function quick_add() {
if (array_var($_GET, 'current') == 'overview-panel') {
ajx_current("reload");
}else {
ajx_current("empty");
}
//---------- REQUEST PARAMS --------------
// $_POST = Array (
// [member] => Array (
// [name] => pepe 333
// [dimension_id] => 1
// [parent_member_id] => 0
// [dimension_id] => 19
// )
// [contact] => Array (
// [email] => slkdjflksjdflksdf@kldsjflkdf.com
// [user] => Array (
// [create-user]=>on
// [type] => 25
// [first_name] =>
// [surname] =>
// )
//----------------------------------------
// Init variables
$max_users = config_option('max_users');
if ($max_users && (Contacts::count() >= $max_users)) {
flash_error(lang('maximum number of users reached error'));
ajx_current("empty");
return;
}
if (!can_manage_security(logged_user())) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
$email = trim(array_var(array_var($_POST, 'contact'),'email')) ;
$member = array_var($_POST, 'member');
$name = array_var($member, 'name');
$firstName = trim(array_var(array_var($_POST, 'contact'),'first_name'));
$surname = trim(array_var(array_var($_POST, 'contact'),'surname'));
$parentMemberId = array_var($member, 'parent_member_id');
$objectType = ObjectTypes::findById(array_var($member, 'object_type_id'))->getName(); // 'person', 'company'
$dimensionId = array_var($member, 'dimension_id');
$company = array_var(array_var(array_var($_POST, 'contact'),'user'),'company_id');
// Create new instance of Contact and set the basic fields
$contact = new Contact();
$contact->setObjectName($name);
if ($firstName) {
$contact->setFirstName($firstName);
}else{
$contact->setFirstName($name);
}
if ($surname) {
$contact->setSurname($surname);
}
$contact->setCompanyId($company);
$contact->setIsCompany($objectType == "company");
if ($parentMemberId){
if ( $companyId = Members::findById($parentMemberId)->getObjectId()) {
$contact->setCompanyId($companyId);
}
}
// Save Contact
try {
DB::beginWork();
$contact->save();
if ($email && is_valid_email($email)) {
if (!Contacts::validateUniqueEmail($email)) {
DB::rollback();
flash_error(lang("email address must be unique"));
return false;
}else{
if (!array_var (array_var(array_var($_POST, 'contact'),'user'), 'create-user')) {
$contact->addEmail($email, 'personal', true);
}
flash_success(lang("success add contact", $contact->getObjectName()));
}
}
// User settings
$user = array_var(array_var($_POST, 'contact'),'user');
$user['username'] = str_replace(" ","",strtolower($name)) ;
$this->createUserFromContactForm($user, $contact->getId(), $email);
// Reload contact again due to 'createUserFromContactForm' changes
Hook::fire("after_contact_quick_add", Contacts::instance()->findById($contact->getId()), $ret);
//.........这里部分代码省略.........
示例12: unarchive
function unarchive()
{
if (!can_manage_dimension_members(logged_user())) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
$member = Members::findById(get_id());
if (!$member instanceof Member) {
flash_error(lang('member dnx'));
ajx_current("empty");
return;
}
if (get_id('user')) {
$user = Contacts::findById($get_id('user'));
} else {
$user = logged_user();
}
if (!$user instanceof Contact) {
ajx_current("empty");
return;
}
try {
DB::beginWork();
set_time_limit(0);
$count = $member->unarchive($user);
evt_add("reload dimension tree", $member->getDimensionId());
ajx_current("back");
flash_success(lang('success unarchive member', $member->getName(), $count));
DB::commit();
} catch (Exception $e) {
DB::rollback();
flash_error($e->getMessage());
ajx_current("empty");
}
}
示例13: delete_custom_report
function delete_custom_report()
{
if (logged_user()->isGuest()) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
$report_id = array_var($_GET, 'id');
$report = Reports::getReport($report_id);
if (!$report->canDelete(logged_user())) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
// if
try {
DB::beginWork();
$report->delete();
DB::commit();
ajx_current("reload");
} catch (Exception $e) {
DB::rollback();
flash_error($e->getMessage());
ajx_current("empty");
}
// try
}
示例14: update_unset_billing_values
function update_unset_billing_values()
{
ajx_current("empty");
if (!logged_user()->isAdministrator()) {
flash_error(lang("no access permissions"));
return;
}
try {
DB::beginWork();
$count = Timeslots::updateBillingValues();
DB::commit();
flash_success(lang("success update billing values", $count));
} catch (Exception $e) {
DB::rollback();
flash_error($e->getMessage());
}
}
示例15: move
function move()
{
if (logged_user()->isGuest()) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
ajx_current("empty");
$id = get_id();
$to = array_var($_GET, 'to', 0);
// TODO: check permissions
$ws = Projects::findById($id);
$parent = Projects::findById($to);
if (isset($ws)) {
if ($to == 0 || isset($parent)) {
$ws->setParentId($to);
$ws->save();
evt_add('workspace_edited', array("is" => $ws->getId(), "name" => $ws->getId(), "color" => $ws->getId(), "parent" => $ws->getParentId()));
}
}
}