本文整理汇总了PHP中Notifier::shareObject方法的典型用法代码示例。如果您正苦于以下问题:PHP Notifier::shareObject方法的具体用法?PHP Notifier::shareObject怎么用?PHP Notifier::shareObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Notifier
的用法示例。
在下文中一共展示了Notifier::shareObject方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: do_share
function do_share()
{
$share_data = array_var($_POST, 'share_data');
if (is_array($share_data)) {
$obj = get_object_by_manager_and_id(array_var($share_data, 'object_id'), array_var($share_data, 'object_manager'));
$emails = array_var($_POST, 'emails');
$companies = array_var($_POST, 'companiesId');
if (!is_array($emails) || !count($emails)) {
flash_error(lang('must specify recipients'));
ajx_current("empty");
return;
}
$people = array();
foreach ($emails as $k => $email) {
// Retrieve users to notify
$lt_pos = strpos_utf($email, '<');
if ($lt_pos !== FALSE) {
// only email address
$email = substr_utf($email, $lt_pos + 1);
$email = str_replace('>', '', $email);
}
if (trim($email) != '') {
$user = Users::findOne(array('conditions' => "`email` = '" . $email . "'"));
if (!$user instanceof User) {
// User not exists -> create one with minimum permissions
try {
DB::beginWork();
$user = $this->createMinimumUser($email, $companies[$k]);
DB::commit();
} catch (Exception $e) {
DB::rollback();
}
}
if ($user instanceof User) {
$people[] = $user;
$canWrite = array_var($share_data, 'allow_edit');
if ($canWrite && !$obj->canEdit($user) || !$obj->canView($user)) {
$this->setObjUserPermission($user, $obj, $canWrite);
}
$this->saveSharedObject($obj, $user);
}
}
}
Notifier::shareObject($obj, $people);
flash_success(lang("success sharing object"));
ajx_current("back");
}
}