本文整理匯總了PHP中Model\User::validateAuth方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::validateAuth方法的具體用法?PHP User::validateAuth怎麽用?PHP User::validateAuth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Model\User
的用法示例。
在下文中一共展示了User::validateAuth方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: article
/**
* 發布一篇文章
*
* @param array $article 文件內容
* @param int $publish 是否真正發布(如果為否,則僅為預覽,輸出至Buffer中)
*
* @return array
*/
public static function article(array $article, $publish = true)
{
\Model\User::validateAuth($article['uid']);
$path = sprintf('article/%u.html', $article['id']);
$message = sprintf('update article %u [%s]', $article['id'], date('Y-m-d H:i:s'));
$blog = Blog::show();
$category = Category::show($article['category_id']);
$now = time();
$publish_time = date('Y-m-d H:i:s', $now);
$tpl_vars = array('blog' => $blog, 'category' => $category, 'article' => $article, 'publish' => $publish, 'publish_date' => date('Y-m-d', $now));
$smarty = \Comm\Smarty::init();
if ($publish) {
$content = $smarty->render('tpl:article', $tpl_vars);
$result = self::publishUserRespos($path, $content, $message);
//發布成功,更新發布時間與發布狀態
try {
Article::update($article, ['state' => 1, 'publish_time' => $publish_time]);
} catch (\Exception $e) {
}
} else {
$result = $smarty->display('tpl:article', $tpl_vars);
}
return $result;
}
示例2: delete
/**
* 刪除一個模板
*
* @param int $id 主鍵ID
* @param string $uid 用戶UID
*
* @return \int
*/
public static function delete($id, $uid = false)
{
$uid || ($uid = \Model\User::validateAuth($uid));
return self::db()->wAnd(['id' => $id, 'user_id' => $uid])->delete(true);
}
示例3: validateAuth
/**
* 檢查指定權限用戶有無操作權限
*
* @param int $tpl_id 模板ID
* @param int $uid 當前登錄用戶UID
*
* @return array TPL-Main數據
*/
public static function validateAuth($tpl_id, $uid = false)
{
$uid || ($uid = \Model\User::validateLogin());
$tpl_main = Main::show($tpl_id);
$validate_uid = isset($tpl_main['user_id']) ? $tpl_main['user_id'] : 0;
\Model\User::validateAuth($validate_uid, $uid);
return $tpl_main;
}