本文整理汇总了PHP中Hook::fire方法的典型用法代码示例。如果您正苦于以下问题:PHP Hook::fire方法的具体用法?PHP Hook::fire怎么用?PHP Hook::fire使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hook
的用法示例。
在下文中一共展示了Hook::fire方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Execute specific controller action
*
* @access public
* @param string $action
* @return InvalidControllerActionError if action name is not valid or true
*/
function execute($action) {
// Prepare action name
$action = trim(strtolower($action));
// If we have valid action execute and done... Else throw exception
if($this->validAction($action)) {
$this->setAction($action);
$ret = true;
Hook::fire('before_action', array(
'controller' => $this,
'action' => $action
), $ret);
if ($ret) {
TimeIt::start("Action");
$this->$action();
TimeIt::stop();
Hook::fire('after_action', array(
'controller' => $this,
'action' => $action
), $ret);
}
return true;
} else {
throw new InvalidControllerActionError($this->getControllerName(), $action);
} // if
} // execute
示例2: text
public function text()
{
$text = nl2br($this->entity->text);
//turn links to clickable
$text = app('App\\Repositories\\PostRepository')->turnLinks($text);
return \Hook::fire('post-text', $text);
}
示例3: render_user_box
/**
* Render user box
*
* @param User $user
* @return null
*/
function render_user_box(Contact $user) {
tpl_assign('_userbox_user', $user);
$crumbs = array();
$crumbs[] = array(
'url' => get_url('help','help_options', array('current' => 'help')),
'text' => lang('help'),
);
$crumbs[] = array(
'url' => logged_user()->getAccountUrl(),
'target' => 'account',
'text' => lang('account'),
);
if (logged_user()->isExecutiveGroup()) {
$crumbs[] = array(
'url' => get_url('administration', 'index'),
'target' => 'administration',
'text' => lang('administration'),
);
}
Hook::fire('render_userbox_crumbs', null, $crumbs);
$crumbs = array_reverse($crumbs);
tpl_assign('_userbox_crumbs', $crumbs);
return tpl_fetch(get_template_path('user_box', 'application'));
} // render_user_box
示例4: create
/**
* Create page
*
* @param array $val
* @return \App\Models\Page
*/
public function create($val)
{
$expected = ['title', 'description', 'website', 'url' => '', 'category'];
/**
* @var $title
* @var $description
* @var $website
* @var $category
* @var $url
*/
extract(array_merge($expected, $val));
if (!empty($title) and !empty($category)) {
$page = $this->model->newInstance();
$page->title = sanitizeText($title, 130);
$page->slug = sanitizeText($url);
$page->user_id = \Auth::user()->id;
$page->description = \Hook::fire('filter-text', sanitizeText($description));
$page->category_id = sanitizeText($category);
$page->website = sanitizeText($website);
$page->save();
$page->save();
$this->event->fire('page.add', [$page]);
return $page;
}
return false;
}
示例5: delete
/**
* Delete
*
* Removing an object is done with the delete method. Pass an id with the
* request and the object should be removed.
* @param int $id
*/
public function delete($id)
{
/*
* Return not found by defaut, just in case you don't override it when
* extending it.
*/
Hook::fire(Hook::EVENT_RESPONSE_NOT_FOUND);
}
示例6: render_user_box
/**
* Render user box
*
* @param User $user
* @return null
*/
function render_user_box(Contact $user)
{
tpl_assign('_userbox_user', $user);
$crumbs = array();
$crumbs[] = array('url' => get_url('help', 'help_options', array('current' => 'help')), 'text' => lang('help'));
$crumbs[] = array('url' => logged_user()->getAccountUrl(), 'target' => 'account', 'text' => lang('account'));
if (logged_user()->isExecutiveGroup()) {
$crumbs[] = array('id' => "userbox-settings", 'url' => '#', 'text' => lang('settings'), 'onclick' => "og.openLink(og.getUrl('more','index',{more_settings_expanded:1})); return false;");
}
Hook::fire('render_userbox_crumbs', null, $crumbs);
$crumbs = array_reverse($crumbs);
tpl_assign('_userbox_crumbs', $crumbs);
return tpl_fetch(get_template_path('user_box', 'application'));
}
示例7: contactCanReadObjectTypeinMember
function contactCanReadObjectTypeinMember($permission_group_ids, $member_id, $object_type_id, $can_write = false, $can_delete = false, $user = null)
{
if ($user instanceof Contact && $user->isAdministrator()) {
return true;
}
$can_write_cond = $can_write ? " AND `can_write` = 1" : "";
$can_delete_cond = $can_delete ? " AND `can_delete` = 1" : "";
$ret = false;
Hook::fire('can_read_ot_in_member', array('pgs' => $permission_group_ids, 'ot' => $object_type_id, 'can_write' => $can_write_cond, 'can_delete' => $can_delete_cond), $ret);
if ($ret) {
return $ret;
}
$res = DB::execute("SELECT permission_group_id FROM " . TABLE_PREFIX . "contact_member_permissions WHERE `member_id` = '{$member_id}' AND `object_type_id` = '{$object_type_id}' AND \r\n\t \t\t\t\t\t\t\t`permission_group_id` IN ( {$permission_group_ids} ) {$can_write_cond} {$can_delete_cond} limit 1");
return $res->numRows() > 0;
}
示例8: render_user_box
/**
* Render user box
*
* @param User $user
* @return null
*/
function render_user_box(User $user)
{
tpl_assign('_userbox_user', $user);
tpl_assign('_userbox_projects', $user->getActiveProjects());
$crumbs = array();
$crumbs[] = array('url' => get_url('help', 'help_options', array('current' => 'help')), 'text' => lang('help'));
$crumbs[] = array('url' => logged_user()->getAccountUrl(), 'target' => 'account', 'text' => lang('account'));
if (logged_user()->isMemberOfOwnerCompany() && logged_user()->isAdministrator()) {
$crumbs[] = array('url' => get_url('administration', 'index'), 'target' => 'administration', 'text' => lang('administration'));
}
Hook::fire('render_userbox_crumbs', null, $crumbs);
$crumbs = array_reverse($crumbs);
tpl_assign('_userbox_crumbs', $crumbs);
return tpl_fetch(get_template_path('user_box', 'application'));
}
示例9: send_reminders
function send_reminders() {
_log("Sending reminders...");
Env::useHelper('permissions');
$sent = 0;
$ors = ObjectReminders::getDueReminders();
foreach ($ors as $or) {
$function = $or->getType();
try {
$ret = 0;
Hook::fire($function, $or, $ret);
$sent += $ret;
} catch (Exception $ex) {
_log("Error sending reminder: " . $ex->getMessage());
}
}
_log("$sent reminders sent.");
}
示例10: add
/**
* Method to add a report
*
* @param array $val
* @return boolean
*/
public function add($val)
{
$expected = ['type' => '', 'url' => '', 'reason' => ''];
/**
* @var $type
* @var $url
* @var $reason
*/
extract($val = array_merge($expected, $val));
if (empty($reason)) {
return false;
}
$report = $this->model->newInstance();
$report->url = sanitizeText($url);
$report->user_id = \Auth::user()->id;
$report->type = sanitizeText($type, 50);
$report->reason = \Hook::fire('filter-text', sanitizeText($reason));
$report->save();
return true;
}
示例11: send
/**
* Method to send message to a user
*
* @param int $userid
* @param string $text
* @param string $image
* @param int $fromUserid
* @return bool
*/
public function send($userid, $text, $image = null, $fromUserid = null)
{
$fromUserid = $fromUserid ? $fromUserid : \Auth::user()->id;
if (!$this->canSendEachOther($userid, $fromUserid)) {
return false;
}
$conversation = $this->conversationRepository->ensureConnection($userid, $fromUserid);
$photo = '';
if ($image) {
$photo = $this->photoRepository->upload($image, ['path' => 'users/' . $fromUserid, 'slug' => 'messages', 'userid' => $fromUserid]);
}
$message = $this->model->newInstance();
$message->text = \Hook::fire('filter-text', sanitizeText($text));
$message->sender = sanitizeText($fromUserid);
$message->receiver = sanitizeText($userid);
$message->image = $photo;
$message->conversation_id = $conversation->id;
$message->save();
$this->event->fire('message.send', [$message]);
$this->realTimeRepository->add($userid, 'message');
return $message;
}
示例12: __construct
/**
* Construct
*
* @return BaseProjectFileRevisions
*/
function __construct()
{
Hook::fire('object_definition', 'ProjectFileRevision', self::$columns);
parent::__construct('ProjectFileRevision', 'project_file_revisions', true);
}
示例13: getEmails
/**
* Returns a list of emails according to the requested parameters
*
* @param string $tag
* @param array $attributes
* @param Project $project
* @return array
*/
function getEmails($account_id = null, $state = null, $read_filter = "", $classif_filter = "", $context = null, $start = null, $limit = null, $order_by = 'received_date', $dir = 'ASC', $join_params = null, $archived = false, $conversation_list = null, $only_count_result = false)
{
$mailTablePrefix = "e";
if (!$limit) {
$limit = user_config_option('mails_per_page') ? user_config_option('mails_per_page') : config_option('files_per_page');
}
$accountConditions = "";
// Check for accounts
$accountConditions = '';
if (isset($account_id) && $account_id > 0) {
//Single account
$accountConditions = " AND {$mailTablePrefix}.account_id = " . DB::escape($account_id);
} else {
// show mails for all visible accounts and classified mails where logged_user has permissions so we don't filter by account_id
/*// show emails from other accounts
$macs = MailAccountContacts::instance()->getByContact(logged_user());
$acc_ids = array(0);
foreach ($macs as $mac) $acc_ids[] = $mac->getAccountId();
// permission conditions
$pgs = ContactPermissionGroups::getPermissionGroupIdsByContactCSV(logged_user()->getId());
if (trim($pgs == '')) $pgs = '0';
$perm_sql = "(SELECT count(*) FROM ".TABLE_PREFIX."sharing_table st WHERE st.object_id = $mailTablePrefix.object_id AND st.group_id IN ($pgs)) > 0";
// show mails for all visible accounts and classified mails where logged_user has permissions
$accountConditions = " AND ($mailTablePrefix.account_id IN (" . implode(",", $acc_ids) . ") OR $perm_sql)";*/
}
// Check for unclassified emails
$classified = '';
if ($classif_filter != '' && $classif_filter != 'all') {
$persons_dim = Dimensions::findByCode('feng_persons');
$persons_dim_id = $persons_dim instanceof Dimension ? $persons_dim->getId() : "0";
$classified = "AND " . ($classif_filter == 'unclassified' ? "NOT " : "");
$classified .= "o.id IN (SELECT om.object_id FROM " . TABLE_PREFIX . "object_members om INNER JOIN " . TABLE_PREFIX . "members m ON m.id=om.member_id WHERE m.dimension_id<>{$persons_dim_id})";
}
// if not filtering by account or classification then check that emails are classified or from one of my accounts
if ($classified == '' && $accountConditions == '') {
$macs = MailAccountContacts::instance()->getByContact(logged_user());
$acc_ids = array(0);
foreach ($macs as $mac) {
$acc_ids[] = $mac->getAccountId();
}
$accountConditions = " AND ({$mailTablePrefix}.account_id IN (" . implode(',', $acc_ids) . ") OR EXISTS (\r\n\t\t\t\t\tSELECT om1.object_id FROM " . TABLE_PREFIX . "object_members om1 \r\n\t\t\t\t\t\tINNER JOIN " . TABLE_PREFIX . "members m1 ON m1.id=om1.member_id \r\n\t\t\t\t\t\tINNER JOIN " . TABLE_PREFIX . "dimensions d1 ON d1.id=m1.dimension_id \r\n\t\t\t\t\tWHERE om1.object_id={$mailTablePrefix}.object_id AND d1.is_manageable=1) ) ";
}
// Check for draft, junk, etc. emails
if ($state == "draft") {
$stateConditions = " {$mailTablePrefix}.state = '2'";
} else {
if ($state == "sent") {
$stateConditions = " {$mailTablePrefix}.state IN ('1','3','5')";
} else {
if ($state == "received") {
$stateConditions = " {$mailTablePrefix}.state IN ('0','5')";
} else {
if ($state == "junk") {
$stateConditions = " {$mailTablePrefix}.state = '4'";
} else {
if ($state == "outbox") {
$stateConditions = " {$mailTablePrefix}.state >= 200";
} else {
$stateConditions = "";
}
}
}
}
}
// Check read emails
if ($read_filter != "" && $read_filter != "all") {
if ($read_filter == "unread") {
$read = "AND NOT ";
$subread = "AND NOT mc.";
} else {
$read = "AND ";
$subread = "AND mc.";
}
$read2 = "id IN (SELECT rel_object_id FROM " . TABLE_PREFIX . "read_objects t WHERE contact_id = " . logged_user()->getId() . " AND id = t.rel_object_id AND t.is_read = '1')";
$read .= $read2;
$subread .= $read2;
} else {
$read = "";
$subread = "";
}
$conversation_cond = "";
$box_cond = "AND {$stateConditions}";
if (isset($conversation_list) && $conversation_list > 0) {
$conversation_cond = "AND e.conversation_last = 1";
}
$extra_conditions = "{$accountConditions} {$classified} {$read} {$conversation_cond} {$box_cond}";
Hook::fire("listing_extra_conditions", null, $extra_conditions);
return self::instance()->listing(array('limit' => $limit, 'start' => $start, 'order' => $order_by, 'order_dir' => $dir, 'extra_conditions' => $extra_conditions, 'count_results' => false, 'only_count_results' => $only_count_result, 'join_params' => $join_params));
}
示例14: __construct
/**
* Construct
*
* @return BaseObjectHandins
*/
function __construct()
{
Hook::fire('object_definition', 'ObjectHandin', self::$columns);
parent::__construct('ObjectHandin', 'object_handins', true);
}
示例15: __construct
/**
* Construct
*
* @return BaseUsers
*/
function __construct()
{
Hook::fire('object_definition', 'User', self::$columns);
parent::__construct('User', 'users', true);
}