PHP Method User::createFromID, codiad Code Examples

This page contains top rated real world PHP examples of method User::createFromID from package codiad extracted from open source projects. You can rate examples to help us improve the quality of examples
Example #1
Show file File: QList.php Project: TBoonX/SlideWiki
0
 public function getUser()
 {
     $user = new User();
     $id = $this->dbGetOne('SELECT user_id FROM user_tests WHERE id=:id', array('id' => $this->id));
     $user->createFromID($id);
     return $user;
 }
Example #2
Show file File: ImpressTransition.php Project: TBoonX/SlideWiki
0
 public function getAllStylesForDeck()
 {
     $transitions = array();
     $results = $this->dbQuery('SELECT * FROM impress_transition WHERE deck_revision_id=:deck_revision_id  GROUP BY user_id', array('deck_revision_id' => $this->deck_id));
     if (!empty($results)) {
         foreach ($results as $result) {
             $t = new User();
             $t->createFromID($result['user_id']);
             array_push($transitions, $t);
         }
     }
     return $transitions;
 }
Example #3
Show file File: Comment.php Project: TBoonX/SlideWiki
0
 public function createFromID($id)
 {
     $this->initConnection();
     $res = $this->dbGetRow('SELECT * FROM comment WHERE id=:id', array('id' => $id));
     $this->id = $id;
     $user = new User();
     $user->createFromID($res['user_id']);
     $this->user = $user;
     $this->item_id = $res['item_id'];
     $this->item_type = $res['item_type'];
     $this->title = html_entity_decode($res['title']);
     $this->text = nl2br(htmlspecialchars(html_entity_decode($res['text'])));
     $this->creationTime = $res['timestamp'];
     $this->replies = $this->getReplies();
 }
Example #4
Show file File: Msg.php Project: TBoonX/SlideWiki
0
   public function send()
   {
       $sender = new User();
       $sender->createFromID($this->sender_id);
       $receiver = new User();
       $receiver->createFromID($this->receiver_id);
       $receiver_email = $receiver->getEmail();
       if ($this->msg_type == 'comment') {
           $tmp = 'comment';
       } else {
           $tmp = 'message';
       }
       $msg_subject = 'New ' . $tmp . ' from ' . $sender->username;
       $msg_body = '
	<table width="400" border="0" cellspacing="1" cellpadding="1" style="width:500px;">
	  <tr>
	    <td  rowspan="3" align="right" valign="top"><img src="http://slidewiki.org/?url=ajax/getAvatarSrc&id=' . $this->sender_id . '" align="top"></td>
	    <td><a href="http://slidewiki.org/user/' . $this->sender_id . '">' . $sender->username . '</a></td>
	    <td align="right">' . date('m/d/Y h:i:s a', time()) . ' </td>
	  </tr>
	  <tr>
	    <td></td>
	    <td align="left"><b>' . $this->title . '</b></td>
	  </tr>
	  <tr>
	    <td></td>
	    <td align="left">' . nl2br($this->content) . '</td>
	  </tr>
	</table><hr/>
	This message was sent to ' . $receiver_email . '. If you don\'t want to receive these emails from SlideWiki in the future, please <a href="http://slidewiki.org">unsubscribe</a>.
	<br/>
	SlideWiki: <a href="http://slidewiki.org">http://slidewiki.org</a>	
	';
       $headers = array();
       $headers[] = "MIME-Version: 1.0";
       $headers[] = "Content-type: text/html; charset=utf-8";
       $headers[] = "From: SlideWiki <admin@slidewiki.org>";
       if (!empty($this->content)) {
           if (mail($receiver_email, $msg_subject, $msg_body, implode("\r\n", $headers))) {
               return 1;
           } else {
               return 0;
           }
       }
       //echo $msg_body;
   }
Example #5
Show file File: controller.class.php Project: TBoonX/SlideWiki
0
 function __construct($model, $controller, $action)
 {
     $this->_controller = $controller;
     $this->_action = $action;
     $this->_model = $model;
     $user_id = SlideWikiAuth::getUserId();
     if ($user_id) {
         $user = new User();
         $user->createFromID($user_id);
         $this->_user = array('is_authorized' => SlideWikiAuth::isAuthorized(), 'id' => $user_id, 'name' => $user->username);
     } else {
         $this->_user = array('is_authorized' => false, 'id' => 0, 'name' => '');
     }
     //$this->$model = new $model;
     if (!$this->_noRender) {
         $this->_template = new Template($controller, $action, $this->_noHeader, $this->_noFooter);
         $this->set('user', $this->_user);
     }
 }
Example #6
Show file File: Question.php Project: TBoonX/SlideWiki
0
 public function createFromID($id)
 {
     $this->initConnection();
     $res = $this->dbGetRow('SELECT * FROM questions WHERE id=:id', array('id' => $id));
     $this->id = $id;
     $user = new User();
     $user->createFromID($res['user_id']);
     $this->user = $user;
     $this->item_id = $res['item_id'];
     $this->question = stripslashes($res['question']);
     $this->answers = $this->getAnswers();
     $this->based_on = $res['based_on'];
     $this->mark = $res['mark'];
     $difficulty = $res['difficulty'];
     //                if ($res['diff_count'] == NULL || $res['diff_count']<=0) $difficulty = $res['difficulty'];
     //                else {
     //                    $difficulty = $res['diff_count'];
     //                    $this->diff_flag = 1;
     //                }
     $this->difficulty = $difficulty;
     $this->diff_count = $res['diff_count'];
     $this->timestamp = $res['timestamp'];
     $this->guessing = $this->guessCount();
 }
Example #7
Show file File: Slide.php Project: TBoonX/SlideWiki
0
 public function getUsageExceptUser($user_id, $ignore_owner = 0)
 {
     $user = new User();
     $user->createFromID($user_id);
     if (!$ignore_owner) {
         $ignore_list = array($user_id);
     } else {
         //ignore the usage by owner
         $ignore_list = array($user_id, $this->owner->id);
     }
     $res = array();
     $query = $this->dbQuery('SELECT deck_content.item_id, deck_content.deck_revision_id FROM deck_content WHERE item_type="slide" AND item_id = :item_id', array('item_id' => $this->id));
     # deck_revision.id - revision id of the deck
     # deck_revision.user_id - owner of this deck revision
     # deck_revision.title - title of this deck revision
     # users.username - username of the owner
     /*$this->dbQuery ( 'SELECT deck_revision.id, deck_revision.title, deck_revision.user_id, users.username
       FROM deck_content INNER JOIN deck_revision ON(deck_revision_id=deck_revision.id) INNER JOIN users ON(deck_revision.user_id=users.id)
       WHERE item_type="slide" AND item_id=' . $this->id . ' GROUP BY deck_revision.id ORDER BY deck_revision.timestamp DESC' );*/
     foreach ($query as $row) {
         $deck = new Deck();
         $deck->createFromIDLite($row['deck_revision_id']);
         if (!in_array($deck->owner->id, $ignore_list)) {
             array_push($res, $deck);
         }
     }
     if (empty($res)) {
         $res = "Not used!";
     }
     return $res;
 }
Example #8
Show file File: User.php Project: TBoonX/SlideWiki
0
 public function getSubscribedUsers($page)
 {
     $extent = $this->feed_page_size;
     $offset = $page * $extent;
     $res = array();
     foreach ($this->dbQuery('SELECT * FROM subscription WHERE item_type="user" AND user_id=' . $this->id . ' LIMIT ' . $offset . ',' . $extent) as $row) {
         $user = new User();
         $user->createFromID($row['item_id']);
         $res[] = $user;
     }
     return $res;
 }
Example #9
Show file File: pptxPresentation.php Project: TBoonX/SlideWiki
0
 public function saveToDB($user_id)
 {
     // create a deck with the name of a presentation
     $content = array();
     $new_deck = new Deck();
     $user = new User();
     $user->createFromID($user_id);
     $new_deck->user = $user;
     $new_deck->comment = "new deck created!";
     $new_deck->title = $this->_title;
     $deck_rev_id = $new_deck->create();
     // get each slide and put it in the deck
     for ($i = 0; $i < $this->_numberof_slides; $i++) {
         $new_slide = new Slide();
         $new_slide->user = $user;
         $new_slide->comment = "new slide created!";
         $slide_content = $this->_slides[$i]->_html_slide;
         $new_slide->content = $slide_content;
         $new_slide->deck = $new_deck->id;
         $new_slide->position = $i + 1;
         $slide_rev_id = $new_slide->create();
         $content[] = $new_slide;
         // populate media_relations table
         if (sizeof($this->_slides[$i]->_pics) != 0) {
             foreach ($this->_slides[$i]->_pics as $pic) {
                 $img = new Media();
                 $img->addRelationsFor($pic->_db_id, $deck_rev_id, $slide_rev_id);
             }
         }
     }
     $new_deck->addContent($content);
     return $new_deck->id;
 }
Example #10
Show file File: Deck.php Project: TBoonX/SlideWiki
0
 public function getInitiator()
 {
     $res = $this->dbGetCol('SELECT user_id FROM deck WHERE id=:id', array('id' => $this->deck_id));
     $user = new User();
     $user->createFromID($res[0]);
     return $user;
 }
Example #11
Show file File: notify_weekly.php Project: TBoonX/SlideWiki
0
 function getNotificationIntervalFor($users)
 {
     foreach ($users as $user_id => $user_params) {
         $user = new User();
         $user->createFromID($user_id);
         $users[$user_id]['notification_interval'] = $user->getNotificationInterval();
     }
     return $users;
 }
Example #12
Show file File: UserController.php Project: TBoonX/SlideWiki
0
 function getAllDeckContributions()
 {
     $user_id = $_GET['id'];
     $user = new User();
     $user->createFromID($user_id);
     $user->email = $user->getEmail();
     $editoreddecks = $user->getEditorDecks();
     $owndecks = array();
     foreach ($user->getContributedDecks() as $c) {
         $n = new Deck();
         $n->createFromIDLite($c);
         $owndecks[] = $n;
     }
     $this->set('editoreddecks', $editoreddecks);
     $this->set('owndecks', $owndecks);
     $this->set('profile', $user);
     $this->set('page_title', $user->username . ' - List of all contributed decks');
 }
Example #13
Show file File: MainController.php Project: TBoonX/SlideWiki
0
 function newDeck()
 {
     // need a better access control here
     if (!$this->_user['is_authorized']) {
         $this->set('authorized', false);
         //die ( 'Please login in to create a new deck!' );
     } else {
         $this->set('authorized', true);
     }
     if (isset($_POST['submit'])) {
         $data = $_POST['deck'];
         $deck = new Deck();
         $deck->title = $data['title'];
         $deck->slug_title = $deck->sluggify($deck->title);
         $user = new User();
         $user->createFromID($this->getCurrentUserID());
         $deck->user = $user;
         $deck->abstract = $data['abstract'];
         $deck->default_theme = $data['theme'];
         $deck->visibility = $data['visibility'];
         $deck->language['id'] = $data['language_id'];
         $deck->language['name'] = $data['language_name'];
         $deck->create();
         $slide_no = $data['slideNo'];
         //add slides
         $content = array();
         for ($i = 1; $i < $slide_no; $i++) {
             $slide = new Slide();
             $slide->user = $user;
             $slide->content = "<h2>new slide</h2>";
             $slide->language['id'] = $data['language_id'];
             $slide->language['name'] = $data['language_name'];
             $slide->translation_status = 'original';
             $slide->create();
             $content[] = $slide;
         }
         $deck->addContent($content);
         $tag = new Tag();
         $tag->item_type = "deck";
         $tag->item_id = $deck->id;
         foreach (explode(',', $data['tags']) as $item) {
             $tag->tag = $item;
             $tag->save();
         }
         header('Location:deck/' . $deck->id . '_' . $deck->slug_title);
     } else {
         $style = new Style();
         $styles_list = $style->getAll();
         $this->set('styles', $styles_list);
         $user_id = $this->getCurrentUserID();
         $user = new User();
         $user->id = $user_id;
         $default_language = $user->getDefaultLanguage();
         if (!$default_language['id']) {
             $default_language['id'] = 'en';
             $default_language['name'] = 'English';
         }
         $this->set('default_language', $default_language);
     }
     $this->set('page_title', 'SlideWiki - Create a new deck');
 }
Example #14
Show file File: htmlPresentation.php Project: TBoonX/SlideWiki
0
 public function saveToDB($user_id, $slides, $meta_data)
 {
     // create a deck with the name of a presentation
     $content = array();
     $new_deck = new Deck();
     $user = new User();
     $user->createFromID($user_id);
     $new_deck->user = $user;
     $new_deck->comment = "Deck imported from HTML file!";
     $new_deck->title = $meta_data['title'];
     $new_deck->create($meta_data['deck_revision_id']);
     // get each slide and put it in the deck
     foreach ($slides as $index => $slide) {
         $new_slide = new Slide();
         $new_slide->user = $user;
         $new_slide->comment = "new slide created!";
         $slide_content = $slide;
         $new_slide->content = $slide_content;
         $new_slide->deck = $new_deck->id;
         $new_slide->position = $index + 1;
         $new_slide->create();
         $content[] = $new_slide;
     }
     $new_deck->addContent($content);
     //$new_deck->commit();
     // save image to server
     // create image entries in the DB table
     return $new_deck->id;
 }
Example #15
Show file File: texPresentation.php Project: TBoonX/SlideWiki
0
 public function saveToDB($user_id, $slides)
 {
     // create a deck with the name of a presentation
     $content = array();
     $new_deck = new Deck();
     $user = new User();
     $user->createFromID($user_id);
     $new_deck->user = $user;
     $new_deck->comment = "new deck created!";
     $new_deck->title = '';
     $new_deck->create();
     // get each slide and put it in the deck
     foreach ($slides as $index => $slide) {
         $new_slide = new Slide();
         $new_slide->user = $user;
         $new_slide->comment = "new slide created!";
         $slide_content = $slide;
         $new_slide->content = $slide_content;
         $new_slide->deck = $new_deck->id;
         $new_slide->position = $index + 1;
         $new_slide->create();
         $content[] = $new_slide;
     }
     $new_deck->addContent($content);
     // save image to server
     // create image entries in the DB table
     return $new_deck->id;
 }
Example #16
Show file File: Revision.php Project: TBoonX/SlideWiki
0
 public function needNewRevision($user_id, $deck)
 {
     if (!$user_id) {
         return -1;
     }
     // user is not logged in
     $user = new User();
     $user->createFromID($user_id);
     if ($user_id != $deck->owner->id && !$user->isMemberOfGroup($deck->id, 'editor')) {
         //user is not the owner of the deck
         return 1;
     } else {
         //user is the owner of the deck or in editorial list
         //check deck usage
         if (count($deck->getUsageExceptUser($user_id, 1))) {
             //deck is used somewhere else
             return 1;
         } else {
             //deck is not used somewhere else
             return 0;
         }
     }
 }