本文整理汇总了PHP中Error::occurred方法的典型用法代码示例。如果您正苦于以下问题:PHP Error::occurred方法的具体用法?PHP Error::occurred怎么用?PHP Error::occurred使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Error
的用法示例。
在下文中一共展示了Error::occurred方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* create
* This is a static function that takes a key'd array for input
* and if everything is good creates the object.
*/
public static function create(array $data)
{
// Make sure we've got a name
if (!strlen($data['name'])) {
Error::add('name', T_('Name Required'));
}
$allowed_array = array('https', 'http', 'mms', 'mmsh', 'mmsu', 'mmst', 'rtsp', 'rtmp');
$elements = explode(":", $data['url']);
if (!in_array($elements['0'], $allowed_array)) {
Error::add('url', T_('Invalid URL must be http:// or https://'));
}
// Make sure it's a real catalog
$catalog = Catalog::create_from_id($data['catalog']);
if (!$catalog->name) {
Error::add('catalog', T_('Invalid Catalog'));
}
if (Error::occurred()) {
return false;
}
// If we've made it this far everything must be ok... I hope
$sql = "INSERT INTO `live_stream` (`name`,`site_url`,`url`,`catalog`,`codec`) " . "VALUES (?, ?, ?, ?, ?)";
$db_results = Dba::write($sql, array($data['name'], $data['site_url'], $data['url'], $catalog->id, $data['codec']));
return $db_results;
}
示例2: T_
}
// Check the mail for correct address formation.
if (!Mailer::validate_address($email)) {
Error::add('email', T_('Invalid email address'));
}
if (!$pass1) {
Error::add('password', T_("You must enter a password"));
}
if ($pass1 != $pass2) {
Error::add('password', T_("Your passwords do not match"));
}
if (!User::check_username($username)) {
Error::add('duplicate_user', T_("Error Username already exists"));
}
// If we've hit an error anywhere up there break!
if (Error::occurred()) {
require_once AmpConfig::get('prefix') . '/templates/show_user_registration.inc.php';
break;
}
/* Attempt to create the new user */
$access = '5';
switch (AmpConfig::get('auto_user')) {
case 'admin':
$access = '100';
break;
case 'user':
$access = '25';
break;
case 'guest':
default:
$access = '5';
示例3: update
/**
* update
* This function is an all encompasing update function that
* calls the mini ones does all the error checking and all that
* good stuff
*/
public function update(array $data)
{
if (empty($data['username'])) {
Error::add('username', T_('Error Username Required'));
}
if ($data['password1'] != $data['password2'] and !empty($data['password1'])) {
Error::add('password', T_("Error Passwords don't match"));
}
if (Error::occurred()) {
return false;
}
if (!isset($data['fullname_public'])) {
$data['fullname_public'] = false;
}
foreach ($data as $name => $value) {
if ($name == 'password1') {
$name = 'password';
} else {
$value = scrub_in($value);
}
switch ($name) {
case 'password':
case 'access':
case 'email':
case 'username':
case 'fullname':
case 'fullname_public':
case 'website':
case 'state':
case 'city':
if ($this->{$name} != $value) {
$function = 'update_' . $name;
$this->{$function}($value);
}
break;
case 'clear_stats':
Stats::clear($this->id);
break;
default:
// Rien a faire
break;
}
}
return $this->id;
}
示例4: show_confirmation
if (!Error::occurred()) {
$url = AmpConfig::get('web_path') . '/admin/access.php';
show_confirmation(T_('Added'), T_('Your new Access Control List(s) have been created'), $url);
} else {
$action = 'show_add_' . $_POST['type'];
require_once AmpConfig::get('prefix') . '/templates/show_add_access.inc.php';
}
break;
case 'update_record':
if (!Core::form_verify('edit_acl')) {
UI::access_denied();
exit;
}
$access = new Access($_REQUEST['access_id']);
$access->update($_POST);
if (!Error::occurred()) {
show_confirmation(T_('Updated'), T_('Access List Entry updated'), AmpConfig::get('web_path') . '/admin/access.php');
} else {
$access->format();
require_once AmpConfig::get('prefix') . '/templates/show_edit_access.inc.php';
}
break;
case 'show_add_current':
case 'show_add_rpc':
case 'show_add_local':
case 'show_add_advanced':
$action = $_REQUEST['action'];
require_once AmpConfig::get('prefix') . '/templates/show_add_access.inc.php';
break;
case 'show_edit_record':
$access = new Access($_REQUEST['access_id']);
示例5: create
public static function create(array $data)
{
$subject = trim(strip_tags($data['subject']));
$message = trim(strip_tags($data['message']));
if (empty($subject)) {
Error::add('subject', T_('Error: Subject Required'));
}
$to_user = User::get_from_username($data['to_user']);
if (!$to_user->id) {
Error::add('to_user', T_('Error: Unknown user'));
}
if (!Error::occurred()) {
$from_user = $data['from_user'] ?: $GLOBALS['user']->id;
$creation_date = $data['creation_date'] ?: time();
$is_read = $data['is_read'] ?: 0;
$sql = "INSERT INTO `user_pvmsg` (`subject`, `message`, `from_user`, `to_user`, `creation_date`, `is_read`) " . "VALUES (?, ?, ?, ?, ?, ?)";
if (Dba::write($sql, array($subject, $message, $from_user, $to_user->id, $creation_date, $is_read))) {
$insert_id = Dba::insert_id();
// Never send email in case of user impersonation
if (!isset($data['from_user']) && $insert_id) {
if (Preference::get_by_user($to_user->id, 'notify_email')) {
if (!empty($to_user->email)) {
$mailer = new Mailer();
$mailer->set_default_sender();
$mailer->recipient = $to_user->email;
$mailer->recipient_name = $to_user->fullname;
$mailer->subject = "[" . T_('Private Message') . "] " . $subject;
$mailer->message = sprintf(T_("You just received a new private message from %s.\n\n\n ----------------------\n %s\n ----------------------\n\n %s\n "), $GLOBALS['user']->fullname, $message, AmpConfig::get('web_path') . "/pvmsg.php?action=show&pvmsg_id=" . $insert_id);
$mailer->send();
}
}
}
return $insert_id;
}
}
return false;
}