コード例 #1
0
ファイル: Category.php プロジェクト: felixonline/core
 function __construct($id = NULL)
 {
     $fields = array('label' => new Type\CharField(), 'cat' => new Type\CharField(), 'active' => new Type\BooleanField(), 'parent' => new Type\ForeignKey('FelixOnline\\Core\\Category'), 'email' => new Type\CharField(), 'twitter' => new Type\CharField(), 'description' => new Type\TextField(), 'order' => new Type\IntegerField(), 'hidden' => new Type\BooleanField(), 'secret' => new Type\BooleanField());
     parent::__construct($fields, $id);
     $currentuser = new CurrentUser();
     if ($this->getSecret() && !$currentuser->isLoggedIn() && !Utility::isInCollege()) {
         throw new \FelixOnline\Exceptions\ModelNotFoundException("This is a secret category and you don't have permission to access it", "Category", $id);
     }
 }
コード例 #2
0
ファイル: API.php プロジェクト: writyfy/app
 public function setLike()
 {
     $user = new CurrentUser();
     if ($user->isLoggedIn()) {
         $alreadyLiked = false;
         while ($row = mysqli_fetch_array($this->result)) {
             if ($row['UserID'] == $user->getCookieID()) {
                 $alreadyLiked = true;
             }
         }
         if ($alreadyLiked) {
             return;
         } else {
             self::DBConnect("likes", $this->ID, $user->getCookieID());
         }
     } else {
         echo "not logged in";
     }
 }