コード例 #1
0
ファイル: ilike.php プロジェクト: night-coder/ignite
 /**
  * Adds the ilike service to user tables;
  * @param unknown_type $post
  * @param unknown_type $userid
  */
 public function addService($post, $userid)
 {
     TuiyoLoader::helper("parameter");
     $table =& TuiyoLoader::table("userplugins", true);
     $table->load(null);
     //blank
     $table->name = "ilike";
     $table->type = "service";
     $table->userid = (int) $userid;
     $table->privacy = '%p00%';
     //get parameters;
     $registry = new JRegistry();
     $postParams = JRequest::getVar('params', array(), 'post', 'array');
     if (count($postParams)) {
         $registry->loadArray($postParams);
         $table->params = $registry->toString();
         //store the username and password and anything else;
     }
     if (!$table->store()) {
         echo $table->getError();
         return false;
         //get the eror;
     }
     return true;
 }
コード例 #2
0
ファイル: notifications.php プロジェクト: night-coder/ignite
 /**
  * TuiyoModelNotifications::loadNotice()
  * Remove LoadNotice
  * @param mixed $noticeID
  * @param mixed $userID
  * @return
  */
 public function loadNotice($noticeID, $userID)
 {
     $nTable = TuiyoLoader::table("notifications", true);
     $document = TuiyoApi::get("document");
     $nTable->load((int) $noticeID);
     if ((int) $userID === (int) $nTable->userid) {
         $nTable->status = 1;
         if (!$nTable->store()) {
             $document->enqueMessage($nTable->getError(), "error");
         }
     }
     return $nTable;
 }
コード例 #3
0
ファイル: categories.php プロジェクト: night-coder/ignite
 public function addCategory($data)
 {
     $catCreator = TuiyoAPI::get("user", null);
     $catTree = TuiyoLoader::table("categories", true);
     $catTree->load(null);
     $catTree->title = trim($data['cattitle']);
     $catTree->parent = (int) $data['catpid'];
     $catTree->slug = trim($data['catslug']);
     $catTree->creator = (int) $catCreator->id;
     $catTree->description = trim($data['catdescription']);
     $catTree->dateadded = date('Y-m-d H:is');
     $catTree->status = (int) $data['catstatus'];
     //print_r( $catTree );
     if (!$catTree->store()) {
         JError::raiseError(TUIYO_SERVER_ERROR, $catTree->getError());
         return false;
     }
     //Restructure the Tree;
     $catTree->restructureTree();
     return true;
 }
コード例 #4
0
ファイル: notify.php プロジェクト: night-coder/ignite
 /**
  * TuiyoNotify::_()
  * 
  * @param mixed $userIdTo
  * @param mixed $title
  * @param mixed $actionLink
  * @param mixed $actionTitle
  * @param string $application
  * @param mixed $template
  * @param mixed $templateVars
  * @return void
  */
 public function _($userIdTo, $title, $actionLink, $actionTitle, $application = 'system', $template = NULL, $templateVars = NULL)
 {
     global $mainframe;
     TuiyoLoader::helper("parameter");
     //1. Check App can send Mail
     //2. Load the user message is being sent to
     $document = TuiyoApi::get("document");
     $userFrom = TuiyoApi::get("user", null);
     $user = TuiyoApi::get("user", (int) $userIdTo);
     $notifyTable = TuiyoLoader::table("notifications", true);
     $notifyParams = TuiyoParameter::load("emails");
     if ($userIdTo < 1) {
         $document->enqueMessage(_("Could not notify the user due to a UserID({$userIdTo}) error"), "error");
         return false;
     }
     //3. Add Notification Title to database;
     $notifyTable->title = $title;
     $notifyTable->userid = $userIdTo;
     $notifyTable->link = $actionLink;
     $notifyTable->linktitle = $actionTitle;
     $notifyTable->application = $application;
     $notifyTable->status = 0;
     $notifyTable->type = $template;
     $notifyTable->template = json_encode($templateVars);
     if (!$notifyTable->store()) {
         $document->enqueMessage(sprintf(_("Could not notify the user due to the following error: %s"), $notifyTable->getError()), "error");
         return false;
     }
     if (!empty($template)) {
         $eTitle = $notifyParams->get($template . "Title");
         $eBody = $notifyParams->get($template . "Body");
         $subject = html_entity_decode($eTitle, ENT_QUOTES);
         $message = html_entity_decode($eBody, ENT_QUOTES);
         TuiyoNotify::sendMail($user->joomla->get('email'), $subject, $message);
     }
 }
コード例 #5
0
ファイル: photos.php プロジェクト: night-coder/ignite
 /**
  * TuiyoModelPhotos::deleteAlbum()
  * Delete Album
  * @param mixed $userID
  * @param mixed $albumID
  * @return void
  */
 public function deleteAlbum($userID, $albumID)
 {
     $aTable = TuiyoLoader::table("albums", TRUE);
     $post = JRequest::get("post");
     $albumID = JRequest::getVar("aid", $albumID);
     //1. Check if this is a new album;
     if (!empty($albumID) || (int) $albumID > 0) {
         $aTable->load((int) $albumID);
         //Check User has permission to edit Album
         if ($aTable->ownerid != (int) $userID) {
             JError::raiseError(TUIYO_SERVER_ERROR, _("You do not have permission to edit This album"));
             return false;
         }
     }
     //2. Delete Photos from albums. i.e set aid to 0;
     $aTable->removeAllPhotosFromAlbum((int) $userID, (int) $albumID);
     $aTableOld = clone $aTable;
     //3 Story Album
     if (!$aTable->delete()) {
         JError::raiseError(TUIYO_SERVER_ERROR, $aTable->getError());
         return false;
     }
     //OK
     return $aTableOld;
 }
コード例 #6
0
ファイル: friends.php プロジェクト: night-coder/ignite
 /**
  * TuiyoModelFriends::isFriendOf()
  * Checks if two users are related
  * @param mixed $userOneID
  * @param mixed $userTwoID
  * @return return relID if exists and false if notexists
  */
 public function isFriendOf($userOneID, $userTwoID)
 {
     $tble = TuiyoLoader::table("friends");
     //Checks that on the user table;
     $rel = $tble->checkRelationship((int) $userOneID, (int) $userTwoID);
     if (intval($rel) > 0) {
         $tble = TuiyoLoader::table("friends");
         $tble->load((int) $rel);
         return (object) $tble;
     }
     return false;
 }
コード例 #7
0
ファイル: messages.php プロジェクト: night-coder/ignite
 /**
  * TuiyoModelMessages::setMessageStatus()
  * Sets the status of the message
  * @param mixed $messageID
  * @param mixed $satusID
  * @param mixed $userID
  * @return void
  */
 public function setMessageStatus($messageID, $statusID, $userID)
 {
     $mTable = TuiyoLoader::table('messages', true);
     //1.load the message
     if (!$mTable->load((int) $messageID)) {
         JError::raiseError(TTUIYO_SERVER_ERROR, _("Message could not be loaded"));
         return false;
     }
     //2. Check permisisons
     if ((int) $userID != ($mTable->user_id_to && $mTable->user_id_from)) {
         JError::raiseError(TUIYO_SERVER_ERROR, _("You do not have permission to change this message status"));
         return false;
     }
     //Change the state
     $mTable->state = !empty($statusID) ? (int) $statusID : $mTable->state;
     $mTable->setMessageFolderCode((int) $mTable->state > 0 ? "read" : "new");
     //3. Store the update
     if (!$mTable->store()) {
         JError::raiseError(TUIYO_SERVER_ERROR, _("Could not update the table"));
         return false;
     }
     //Good JOB!.
     return true;
 }
コード例 #8
0
ファイル: events.php プロジェクト: night-coder/ignite
 /**
  * TuiyoModelEvents::addEvent()
  * Creates and stores a new User Event
  * @param mixed $userID
  * @param mixed $postData
  * @return void
  */
 public function addEvent($userID, $postData)
 {
     $eventTable = TuiyoLoader::table('events', true);
     $rsvpTable = TuiyoLoader::table('eventsrsvp', true);
     $auth = TuiyoAPI::get('authentication');
     $doc = TuiyoAPI::get('document');
     //Must be loggged IN
     $auth->requireAuthentication();
     $eventTable->title = trim($postData['title']);
     if (empty($eventTable->title)) {
         $doc->enqueMessage(_('You did not specify an event title'), 'error');
         return false;
     }
     $eventTable->location = trim($postData['location']);
     $eventTable->street = trim($postData['street']);
     $eventTable->city = trim($postData['city']);
     $eventTable->startdate = date('Y-m-d', strtotime($postData['startdate']));
     $eventTable->enddate = date('Y-m-d', strtotime($postData['enddate']));
     $startYear = date('Y', strtotime($postData['startdate']));
     $startMonth = date('m', strtotime($postData['startdate']));
     $startDay = date('d', strtotime($postData['startdate']));
     $startHour = (int) $postData['startTimeHour'];
     $startMin = (int) $postData['startTimeMin'];
     $startSec = (int) $postData['startTimeSec'];
     $endYear = date('Y', strtotime($postData['enddate']));
     $endMonth = date('m', strtotime($postData['enddate']));
     $endDay = date('d', strtotime($postData['enddate']));
     $endHour = (int) $postData['endTimeHour'];
     $endMin = (int) $postData['endTimeMin'];
     $endSec = (int) $postData['endTimeSec'];
     $startTime = mktime($startHour, $startMin, $startSec, $startMonth, $startDay, $startYear);
     $endTime = mktime($endHour, $endMin, $endSec, $endMonth, $endDay, $endYear);
     if ($endTime < $startTime) {
         $doc->enqueMessage(_('The event end Date/Time cannot be before the start Date/Time'), "error");
         return false;
     }
     $eventTable->starttime = date('Y-m-d H:i:s', $startTime);
     $eventTable->endtime = date('Y-m-d H:i:s', $endTime);
     $eventTable->description = $postData['description'];
     $eventTable->poster = trim(htmlspecialchars_decode($postData['poster']));
     $eventTable->privacy = (int) $postData['privacy'];
     $eventTable->createdby = (int) $userID;
     if (!$eventTable->store()) {
         $doc->enqueueMessage($eventTable->getError(), "error");
         return false;
     }
     //addHost to Event
     $rsvpTable->eventid = $eventTable->eventid;
     $rsvpTable->role = 'host';
     $rsvpTable->userid = $eventTable->createdby;
     $rsvpTable->approved = 1;
     if (!$rsvpTable->store()) {
         $eventTable->delete();
         $doc->enqueueMessage(_('An error occured whilst adding you to the event'), "error");
         $doc->enqueueMessage($eventTable->getError(), "error");
         return false;
     }
     return true;
 }
コード例 #9
0
ファイル: uploads.php プロジェクト: night-coder/ignite
 /**
  * Produces an archive of files 
  * 
  * TuiyoUploads::archiveFiles()
  * 
  * @param mixed $userID
  * @param mixed $files
  * @return link on success, raises error on failure
  */
 public function archiveFiles($userID, $files)
 {
     //move the file to the cache
     $targetCache = JPATH_CACHE . DS;
     $targetFolder = $targetCache . DS . $this->_randomCode(4);
     $targetName = $targetFolder . DS . $this->_randomCode(4) . ".archive.zip";
     $archiveFiles = array();
     $archiveZip = new ZipArchive();
     //Create Folder;
     if (JFolder::create($targetFolder)) {
         //create the file and throw the error if unsuccessful
         if ($archiveZip->open($targetName, ZIPARCHIVE::CREATE) !== true) {
             trigger_error(_("Could not open {$targetName} archive"), E_USER_ERROR);
             return false;
         }
         //Archive the files
         foreach ($files as $file) {
             $name = JFile::getName($file);
             $dest = $targetFolder . DS . $name;
             if (!JFile::copy($file, $dest)) {
                 trigger_error(_("Could not archive files"), E_USER_ERROR);
                 return false;
             }
             //add the File
             $archiveZip->addFile($dest, $name);
         }
     }
     $archiveZip->close();
     //If the achive exists! copy it to user resource!
     if (JFile::exists($targetName)) {
         if (JFile::move($targetName, $targetCache . DS . basename($targetName))) {
             JFolder::delete($targetFolder);
             $fData = array("name" => basename($targetName));
             //Save to the resources table
             $resourceTable =& TuiyoLoader::table("resources", true);
             $resourceLink =& $resourceTable->saveFile($fData, $this->_fileType);
             return $resourceLink;
         }
     }
     return false;
 }
コード例 #10
0
ファイル: groups.php プロジェクト: night-coder/ignite
 /**
  * TuiyoModelGroups::getGroup()
  * Gets a group from the databse
  * @param mixed $groupID
  * @param mixed $userID
  * @return
  */
 public function getGroup($groupID)
 {
     $user = TuiyoAPI::get("user", NULL);
     $gTable = TuiyoLoader::table("groups", true);
     $gData = $gTable->loadSingleGroup((int) $groupID);
     //1. Check that group Exists
     if (!is_object($gData) || !isset($gData->groupID) || $gData->groupID < 1) {
         return false;
     }
     //2. Is user Createor?
     $gData->isAdmin = $gData->creatorID != $user->id ? 0 : 1;
     return $gData;
 }
コード例 #11
0
ファイル: articles.php プロジェクト: night-coder/ignite
 /**
  * 
  * Enter description here ...
  * @param unknown_type $user
  * @param unknown_type $data
  */
 public function editSaveArticle($user, $data)
 {
     $aTable = TuiyoLoader::table("posts", true);
     $aTimeline = TuiyoAPI::get("activity");
     $aID = isset($data["ID"]) ? (int) $data["ID"] : null;
     $aTable->load($aID);
     //$data['postcontent'] = $this->removeTags( $data['postcontent'] );
     $aTable->bind($data);
     $date = date('Y-m-d H:i:s');
     $aTable->author = $user->id;
     $aTable->createdate = empty($aTable->ID) ? $date : "";
     $aTable->posttitle = $this->removeTags($aTable->posttitle, "");
     $aTable->postcontent = $this->removeTags($aTable->postcontent);
     $aTable->postexcerpt = $this->removeTags($aTable->postexcerpt, "");
     $aTable->postexcerpt = !empty($aTable->postexcerpt) ? substr($aTable->postexcerpt, 0, 200) : substr($aTable->postcontent, 0, 200);
     $aTable->poststatus = 0;
     $aTable->postmodified = empty($aTable->ID) ? "" : $date;
     $aTable->postname = str_replace(array(" ", "(", ")", "-", "&", "%", ",", "#"), "-", substr($aTable->posttitle, 0, 100));
     $aTable->commentCount = 0;
     if (empty($aTable->author) || empty($aTable->posttitle) || empty($aTable->postcontent)) {
         JError::raiseError(TUIYO_SERVER_ERROR, _("Articles require at least a title, and some content"));
         return false;
     }
     //Store the Article if successful
     if (!$aTable->store()) {
         JError::raiseError(TUIYO_SERVER_ERROR, $aTable->getError());
         return false;
     }
     //Map Categories
     foreach ($data['categories'] as $category) {
         $aCatMaps = TuiyoLoader::table("categoriesmaps", true);
         $aCatMaps->load(null);
         //make sure we are loading a new element
         $aCatMaps->resourceid = $aTable->ID;
         $aCatMaps->maptype = "article";
         $aCatMaps->ownerid = $aTable->author;
         $aCatMaps->categoryid = (int) $category;
         if (!$aCatMaps->store()) {
             JError::raiseError(TUIYO_SERVER_ERROR, $aCatMaps->getError());
             return false;
         }
         unset($aCatMaps);
     }
     $aLink = TUIYO_INDEX . '&view=articles&do=read&aid=' . $aTable->ID;
     $aActivityTmpl = '<div class="activityBodyTitle"><a href="' . $aLink . '">' . $aTable->posttitle . '</a></div>';
     $aActivityTmpl .= $aTable->postexcerpt;
     //Publish activity story
     $aTimeline->publishOneLineStory($user, $aActivityTmpl, "article", NULL, NULL, array(), "article" . $aTable->ID);
     return true;
 }
コード例 #12
0
ファイル: apps.php プロジェクト: night-coder/ignite
 /**
  * TuiyoControllerApps::remove()
  * Removes an application from a user profile
  * @return void
  */
 public function remove()
 {
     $tble = TuiyoLoader::table("userapps");
     $post = JRequest::get('post');
     $user = $GLOBALS['API']->get("user");
     $model = $this->getModel("applications");
     $appName = strval($post['app']);
     //Check The user Token
     if (!JRequest::checkToken() || $user->id != (int) $post['uid']) {
         trigger_error(_("Invalid Token. Access Denied"), E_USER_ERROR);
         return false;
     }
     //1a. Check that user does not already have App!
     //    and that there is actually an application with this id
     if ($tble->userHasApp($appName, $user->id) && $this->_appExists($appName)) {
         if (!$tble->uninstallUserApp($appName, $user->id)) {
             trigger_error(_("Could not remove the application"), E_USER_ERROR);
             return false;
         }
         //Trigger after application unistall events
         TuiyoEventLoader::preparePlugins("admin");
         $GLOBALS["events"]->trigger("onApplicationUnistall", $appName);
         //4. Increment the application userCount;
         $tble->decrAppUserCount($appName, 1);
     }
     //5.Redirect to their new app!
     $redirectMessage = sprintf(_("The %s application has been un-installed from your account, and all data removed. "), $appName);
     $redirectURL = JRoute::_(TUIYO_INDEX . '&view=profile&do=homepage');
     $this->setRedirect($redirectURL, $redirectMessage, "notice");
     $this->redirect();
 }
コード例 #13
0
ファイル: loader.php プロジェクト: night-coder/ignite
 /**
  * TuiyoLoader::table()
  * Loads a library table
  * @param mixed $fileName
  * @param bool $createInstance
  * @param mixed $parameters
  * @return void
  */
 public function table($fileName, $createInstance = true, $parameters = null)
 {
     TuiyoLoader::import($fileName, 'table');
     $parameters = !is_null($parameters) ? $parameters : JFactory::getDBO();
     if ($createInstance) {
         //Table File
         $tableClass = ucfirst(TUIYO_LIB) . 'Table' . ucfirst(self::$_loaded[$fileName]);
         //Had we loaded it before
         if (in_array($tableClass, self::$_stored["tables"])) {
             $object = self::$_stored["tables"][$tableClass];
             if (is_object($object)) {
                 return $object;
             } else {
                 unset(self::$_stored["tables"][$tableClass]);
                 TuiyoLoader::table($fileName, $createInstance, $parameters);
             }
         }
         $table = new $tableClass($parameters);
         self::$_stored["tables"][$tableClass] =& $table;
         return $table;
     }
 }
コード例 #14
0
ファイル: resources.php プロジェクト: night-coder/ignite
 /**
  * TuiyoModelResources::delete()
  * 
  * @param mixed $userID
  * @param mixed $fileIDs
  * @return
  */
 public function delete($fileID)
 {
     //Load the resources table
     $resourceTable =& TuiyoLoader::table("resources", true);
     $resourceTable->load((int) $fileID);
     $resourceTableOld = clone $resourceTable;
     //Delete the file from the server
     if (isset($resourceTable->filePath)) {
         $fileSource = $resourceTable->filePath . $resourceTable->fileName;
         //joomla !!
         jimport('joomla.filesystem.file');
         jimport('joomla.filesystem.path');
         JPath::setPermissions($fileSource, 0777, 0777);
         //now attempt to delete the database entry!
         if (!$resourceTable->delete()) {
             trigger_error(sprintf(_("Could not remove FILE:%s from DB"), $resourceTable->resourceID), E_USER_ERROR);
             return false;
         }
         //echo $photosTableOld->contentType;
         if ($resourceTableOld->contentType == "PHOTOS") {
             $photosTable =& TuiyoLoader::table("photos", true);
             $photosTable->deleteItem((int) $resourceTableOld->resourceID);
         }
         if (!JFile::delete($fileSource)) {
             trigger_error(sprintf(_("Could not delete %s"), $resourceTableOld->fileName), E_USER_ERROR);
             return false;
         }
     }
     unset($resourceTableOld);
     unset($resourceTable);
     return true;
 }
コード例 #15
0
ファイル: chatrooms.php プロジェクト: night-coder/ignite
 /**
  * TuiyoTableChatRooms::createRoomBetweenParticipants()
  * Creates a new chat room
  * @param mixed $initiator
  * @param mixed $member
  * @return void
  */
 public function createRoomBetweenParticipants($initiator, $member)
 {
     $initiator = (int) $initiator;
     $member = (int) $member;
     //Chat Room Users Table
     $curTable = TuiyoLoader::table('chatusersrooms', true);
     $user1Obj = TuiyoAPI::get("user", $initiator);
     $user2Obj = TuiyoAPI::get("user", $member);
     //1st we have to create a room;
     if (empty($initiator) || empty($member)) {
         JError::raiseError(TUIYO_SERVER_ERROR, _('Could not find particpants, imposible to create room'));
         return false;
     }
     $this->load(null);
     $this->name = $initiator . $member . date('YmdHis');
     $this->datafile = $this->name . '.txt';
     $this->status = 0;
     $this->usercount = 2;
     if (!$this->store()) {
         JError::raiseError(TUIYO_SERVER_ERROR, $this->getError());
         return false;
     }
     //2nd Add Participants
     $curTable->load(null);
     $roomID = $this->id;
     $userA = clone $curTable;
     $userB = clone $curTable;
     $userA->username = $user1Obj->username;
     $userA->userid = $user1Obj->id;
     $userA->room = $roomID;
     if (!$userA->store()) {
         $this->delete();
         JError::raiseError(TUIYO_SERVER_ERROR, $userA->getError());
         return false;
     }
     $userB->username = $user2Obj->username;
     $userB->userid = $user2Obj->id;
     $userB->room = $roomID;
     if (!$userB->store()) {
         $this->delete();
         $userA->delete();
         JError::raiseError(TUIYO_SERVER_ERROR, $userB->getError());
         return false;
     }
     unset($curTable);
     //3rd Create a data file; //joomla !!
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.path');
     $path = TUIYO_FILES . DS . 'chat';
     $filename = $path . DS . $this->datafile;
     if (!JFile::exists($filename)) {
         JFile::write($filename, '');
         if (!JFile::exists($filename)) {
             $this->delete();
             $userA->delete();
             $userB->delete();
             JError::raiseError(TUIYO_SERVER_ERROR, _('Could not create chat Log'));
         }
         //JPath::setPermissions( $filename , 0777 , 0777 );
     }
     return $this;
 }
コード例 #16
0
ファイル: activity.php プロジェクト: night-coder/ignite
 /**
  * TuiyoActivity::publishOneLineStory()
  * Application source
  * @param mixed $thisUser
  * @param mixed $storyLine
  * @param object $thatUser
  * @param mixed $tmplVars
  * @return void
  */
 public function publishOneLineStory($thisUser, $storyLine, $source, $thatUser = NULL, $tmplID = NULL, $tmplVars = array(), $type = "activity")
 {
     $mTimeline =& TuiyoLoader::model("timeline", true);
     $tTemplate =& TuiyoLoader::table("timelinetmpl", true);
     //Whose activity?
     if (!is_object($thisUser) || empty($thisUser)) {
         $thisUser = TuiyoAPI::get("user", null);
     }
     //ThatUser must be an object;
     if (!is_null($thatUser) && !is_object($thatUser)) {
         JError::raiseError(_("ThatUser Must be an object"));
         return false;
     }
     //ThatUser
     $thatUser = (object) $thatUser;
     if (empty($tmplID)) {
         //First Save the template
         $tTemplate->load(null);
         $tTemplate->appName = strval($source);
         $tTemplate->identifier = $tTemplate->appName;
         $tTemplate->title = $storyLine;
         $tTemplate->type = 0;
         $tTemplate->resources = null;
         $tTemplate->body = null;
         $tTemplate->variables = json_encode((array) $tmplVars);
         $tTemplate->thisUserID = $thisUser->id;
         $tTemplate->thatUserID = $thatUser->id;
         if (!$tTemplate->store()) {
             trigger_error($tTemplate->getError(), E_USER_ERROR);
             return false;
         }
         $tmplID = $tTemplate->ID;
     }
     //Then save a parsed story in the timeline.
     $activity = array("ptext" => $storyLine, "source" => strval($source), "template" => $tmplID, "sharewith" => array("p00"));
     if (($story = $mTimeline->setStatus($thisUser->id, $activity, $type)) === FALSE) {
         JError::raiseError(_("Tuiyo could not save the activity"));
         return false;
     }
     //Compete
     return array("code" => TUIYO_OK, "error" => null, "tmpl" => $tmplID, "story" => $story);
 }
コード例 #17
0
ファイル: tuiyo.php プロジェクト: night-coder/ignite
 /**
  * TuiyoModelTuiyo::deleteField()
  * Deletes a field from the database
  * @param mixed $fieldID
  * @return
  */
 public function deleteField($fieldID)
 {
     //Load the fields table, and creat an instance
     $table = TuiyoLoader::table("fields", true);
     //Load the field;
     $table->load((int) $fieldID);
     //Delete The field
     if (!$table->delete()) {
         trigger_error($table->getError(), E_USER_ERROR);
         return false;
     }
     //OK
     return true;
 }
コード例 #18
0
ファイル: timeline.php プロジェクト: night-coder/ignite
 /**
  * TuiyoModelTimeline::setStatusComment()
  * @param mixed $userID
  * @param mixed $postData
  * @param mixed $options
  * @return void
  */
 public function setStatusComment($userID, $postData, $options = array())
 {
     $commenter = TuiyoApi::get("user", null);
     $table = TuiyoLoader::table("timeline");
     $table->load(null);
     //print_R($postData);
     $statusText = strval($postData['commentbody']);
     //get out all mentions in the update string
     preg_match_all('#@([\\d\\w]+)#', $statusText, $mentions);
     preg_match_all('/#([\\d\\w]+)/', $statusText, $hashTags);
     $table->tags = sizeof($hashTags[1]) > 0 ? json_encode($hashTags[1]) : null;
     $table->mentions = sizeof($mentions[1]) > 0 ? json_encode($mentions[1]) : null;
     $table->userID = (int) $userID;
     $table->template = null;
     $table->datetime = date('Y-m-d H:i:s');
     $table->data = $statusText;
     $table->type = "comment";
     $table->source = isset($postData['source']) ? $postData['source'] : "web";
     $table->source = strval($table->source);
     $table->inreplyto = isset($postData['inreplyto']) ? (int) $postData['inreplyto'] : JError::raiseError(403, _("Invalid activity ID"));
     if (!$table->store()) {
         trigger_error($table->getError(), E_USER_ERROR);
         return false;
     }
     //Send Notifications to All users participating in this discussion
     TuiyoLoader::library("mail.notify");
     $getParticipants = $table->getAllCommenters($table->inreplyto);
     $firstAuthors = array();
     //Notify Authors
     foreach ($getParticipants["author"] as $author) {
         $firstAuthors[] = $author;
         if ($userID != $author) {
             $userTo = TuiyoAPI::get("user", $author);
             $actionLink = JRoute::_(TUIYO_INDEX . "&view=profile&do=viewStatus&user={$userTo->username}&id={$table->inreplyto}");
             $emailTitle = sprintf(_("%s commented on your wall post"), "@" . $commenter->username);
             $emailBody = "";
             //str_replace( $tSearch , $tVars , $notifyParams->get( "connectionRequestEmailBody" , null ) );
             //echo $notifyEmail ;
             TuiyoNotify::_($userTo->id, $emailTitle, $actionLink, _("View Status"));
             TuiyoNotify::sendMail($userTo->email, $emailTitle, $emailBody);
         }
     }
     //Notify Participants
     foreach ($getParticipants["participant"] as $tookpart) {
         if ($userID != $tookpart) {
             $firstauthor = TuiyoAPI::get("user", (int) $firstAuthors[0]);
             $userTo = TuiyoAPI::get("user", $tookpart);
             $actionLink = JRoute::_(TUIYO_INDEX . "&view=profile&do=viewStatus&user={$firstauthor->username}&id={$table->inreplyto}");
             $emailTitle = sprintf(_("%s commented on %2s wall post"), "@" . $commenter->username, "@" . $firstauthor->username);
             $emailBody = "";
             //str_replace( $tSearch , $tVars , $notifyParams->get( "connectionRequestEmailBody" , null ) );
             //echo $notifyEmail ;
             TuiyoNotify::_($userTo->id, $emailTitle, $actionLink, _("View Status"));
             TuiyoNotify::sendMail($userTo->email, $emailTitle, $emailBody);
         }
     }
     return $table;
 }
コード例 #19
0
ファイル: user.php プロジェクト: night-coder/ignite
 /**
  * TuiyoUser::createProfile()
  * 
  * @param mixed $data
  * @return
  */
 public function createProfile($data)
 {
     //Do we have data to deal with?
     if (!isset($data) || empty($data)) {
         $this->_setErrors(TUIYO_SERVER_ERROR, _("Invalid UserData, Could not create Profile"));
         return false;
     }
     //Get required table!
     $table =& TuiyoLoader::table("users", true);
     //Name required
     if (empty($data['profileName'])) {
         $this->_setErrors(TUIYO_SERVER_ERROR, _("Profile name required to create a profile"));
         return false;
     }
     //die;
     $table->bind($data);
     //Make sure this variables are what we expect
     $table->userID = $this->id;
     $table->dateCreated = date('Y-m-d H:i:s');
     $table->sex = (int) $table->sex;
     //store the new user
     if (!$table->storeObj()) {
         $this->_setErrors(TUIYO_SERVER_ERROR, $table->getError());
         return false;
     }
     //Yuppee!
     return true;
 }
コード例 #20
0
ファイル: params.php プロジェクト: night-coder/ignite
 /**
  * TuiyoParams::getSocialBook()
  * Gets social Book Form
  * @param mixed $formID
  * @param bool $frontPage
  * @param bool $showSubmit
  * @return
  */
 public function getSocialBook($userID, $formID = NULL, $frontPage = TRUE, $showSubmit = TRUE)
 {
     $sfTable = TuiyoLoader::table("fields", true);
     $sfEls = $sfTable->listAll();
     /** Load Social Data ***/
     $this->loadParams("user.social", $userID);
     /** Build the form ****/
     $form = TuiyoAPI::get("form", "user.social");
     foreach ((array) $sfEls as $element) {
         //Smart Description
         $description = $element->required > 0 ? _("This field IS required, ") : _("This field IS Not required,");
         $description .= $element->indexed > 0 ? _("This field IS searchable, ") : _("This field IS NOT searchable,");
         $description .= $element->visible > 0 ? _("This field IS visible on profile. ") : _("This field IS NOT visible on profile. ");
         $description .= !empty($element->descr) && !is_array($element->descr) ? $element->descr : null;
         $defaultValue = $this->get($element->name, $element->defaultvalue);
         //switch element type
         switch ($element->type) {
             case "text":
             case "password":
                 $args = array("name" => $element->name, "label" => $element->title, "description" => $description, "value" => !empty($defaultValue) && !is_array($defaultValue) ? $defaultValue : null);
                 $form->add($element->type, $args["name"], $args);
                 break;
             case "textarea":
                 $args = array("name" => $element->name, "label" => $element->title, "description" => $description, "innerHTML" => !empty($defaultValue) && !is_array($defaultValue) ? $defaultValue : null);
                 $form->add("textarea", $args["name"], $args);
                 break;
             case "radiogroup":
             case "droplist":
             case "select":
                 $args = array("name" => $element->name, "label" => $element->title, "value" => !empty($defaultValue) && !is_array($defaultValue) ? $defaultValue : null, "options" => array(), "description" => $description);
                 //get Obtions
                 $childOptions = array();
                 foreach ($childOptions as $child) {
                     $optionValue = $child->attributes("value");
                     $optionName = $child->data();
                     $args["options"][$optionName] = $optionValue;
                 }
                 $form->add($element->type, $args["name"], $args);
                 break;
             default:
                 continue;
                 break;
         }
     }
     //hidden fields
     $form->add("hidden", "paramKey", array("type" => "hidden", "name" => "paramKey", "value" => "user.social"));
     return $form->outPutForm($formID, $frontPage, $showSubmit);
 }
コード例 #21
0
ファイル: widgets.php プロジェクト: night-coder/ignite
 public function getMyPage($userID)
 {
     $wTable = TuiyoLoader::table("widgets", TRUE);
     $columns = $wTable->getWidgets((int) $userID);
     //Format into LayoutData;
     $layOutData = array();
     foreach ($columns as $column) {
         $tabID = $column->tabID;
         $colID = $column->colID;
         $widID = $column->widgetID;
         $wItem = NULL;
         $cItem = NULL;
         //ADD Tabs
         if (!is_array($layOutData[$tabID])) {
             $layOutData[$tabID] = array("id" => "t" . $column->tabID, "title" => $column->tabTitle, "data" => array());
         }
         //ADD columns
         if (!empty($colID) && !array_key_exists($colID, $layOutData[$tabID]["data"])) {
             $cItem = array("id" => "c" . $colID, "size" => $column->colSize . "%", "widgetData" => array());
             //die;
             $layOutData[$tabID]["data"][$colID] = $cItem;
         }
         //Add Widgets
         if (!empty($widID)) {
             $wItem = array("id" => "w" . $widID, "url" => $column->widgetURL, "title" => $column->widgetTitle, "color" => "red", "params" => json_decode($column->widgetParams));
             $layOutData[$tabID]["data"][$colID]["widgetData"][] = $wItem;
         }
     }
     $layOut = array();
     foreach ($layOutData as $tab) {
         $tabItem = array("id" => $tab["id"], "title" => $tab["title"], "data" => array());
         if (is_array($tab["data"])) {
             foreach ($tab["data"] as $column) {
                 $tabItem["data"][] = $column;
             }
         }
         $layOut[] = $tabItem;
     }
     return $layOut;
 }
コード例 #22
0
ファイル: welcome.php プロジェクト: night-coder/ignite
 public function auth()
 {
     JRequest::setVar("tmpl", "component");
     $user = $GLOBALS['API']->get('user', null);
     $mainframe = $GLOBALS['mainframe'];
     //If user is not guest send back to homepage
     if (!$user->joomla->get('guest')) {
         $mainframe->redirect(JRoute::_(TUIYO_INDEX . "&amp;view=welcome", FALSE));
         return false;
     }
     $view = $this->getView('welcome', 'html');
     $invite = JRequest::getString("ic", NULL, 'request');
     $inviteeN = NULL;
     $inviteeE = NULL;
     if (!empty($invite)) {
         $iTable = TuiyoLoader::table("invites");
         $iObject = $iTable->findInvite($invite);
         if (!empty($iObject) && is_object($iObject)) {
             $inviteeN = $iObject->name;
             $inviteeE = $iObject->email;
         }
         $view->assignRef("inviteCode", $invite);
         $view->assignRef("inviteeName", $inviteeN);
         $view->assignRef("inviteeEmail", $inviteeE);
     }
     $view->showAuthPage($invite, $inviteeN);
 }
コード例 #23
0
ファイル: core.php プロジェクト: night-coder/ignite
 /**
  * TuiyoControllerCore::createUser()
  * Adding a user to the core user Table. Ported from JUser
  * @param mixed $userid
  * @return
  */
 public function createUser($userid = NULL)
 {
     global $mainframe;
     // Check for request forgeries
     JRequest::checkToken() or jexit('Invalid Token');
     // Get required system objects
     $user = clone JFactory::getUser();
     $pathway =& $mainframe->getPathway();
     $config =& JFactory::getConfig();
     $authorize =& JFactory::getACL();
     $document =& JFactory::getDocument();
     $params =& TuiyoAPI::get("params");
     $wasInvited = false;
     // If user registration is not allowed, show 403 not authorized.
     $params->loadParams("system.global");
     //Allow registration or invite?
     $enableReg = (bool) $params->get("siteAllowRegistration", FALSE);
     $usersConfig =& JComponentHelper::getParams('com_users');
     $welcomeAuth = JRoute::_(TUIYO_INDEX . '&amp;view=welcome&do=auth');
     if ($usersConfig->get('allowUserRegistration') == '0' && !$enableReg) {
         $this->setRedirect($welcomeAuth, _("Registration is currently disabled via this route"), "error");
         return false;
     } else {
         if ($enableReg) {
             $inviteCode = JRequest::getString('inviteCode', '', 'post');
             $inviteEmail = JRequest::getString('email', '', 'post');
             $inviteTable = TuiyoLoader::table('invites', true);
             $inviteObject = $inviteTable->findInvite((string) $inviteCode);
             if (empty($inviteCode) || empty($inviteObject) || !is_object($inviteObject) || $inviteObject->email != $inviteEmail) {
                 $this->setRedirect($welcomeAuth, _("Please provide a valid Invitation code"), "error");
                 return false;
             }
             $wasInvited = TRUE;
         } else {
             $this->setRedirect($welcomeAuth, _("Registration is currently disabled"), "error");
             return false;
         }
     }
     // Initialize new usertype setting
     $newUsertype = $usersConfig->get('new_usertype');
     if (!$newUsertype) {
         $newUsertype = 'Registered';
     }
     // Bind the post array to the user object
     if (!$user->bind(JRequest::get('post'), 'usertype')) {
         $this->setRedirect($welcomeAuth, $user->getError(), "error");
         return false;
     }
     // Set some initial user values
     $user->set('id', 0);
     $user->set('usertype', $newUsertype);
     $user->set('gid', $authorize->get_group_id('', $newUsertype, 'ARO'));
     $date =& JFactory::getDate();
     $user->set('registerDate', $date->toMySQL());
     // If user activation is turned on, we need to set the activation information
     $useractivation = $usersConfig->get('useractivation');
     if ($useractivation == '1') {
         jimport('joomla.user.helper');
         $user->set('activation', JUtility::getHash(JUserHelper::genRandomPassword()));
         $user->set('block', '1');
     }
     //Acepted Terms?
     $terms = JRequest::getVar("acceptTerms", 0, 'post');
     if (!(bool) $terms) {
         $msg = _('You MUST pledge to abide by our terms of use');
         $this->setRedirect($welcomeAuth, $msg, 'error');
         return false;
     }
     // Send registration confirmation mail
     $password = JRequest::getString('password', '', 'post', JREQUEST_ALLOWRAW);
     $password2 = JRequest::getString('password2', '', 'post', JREQUEST_ALLOWRAW);
     $password = preg_replace('/[\\x00-\\x1F\\x7F]/', '', $password);
     //Disallow control chars in the email
     // do a password safety check
     // so that "0" can be used as password e.g.
     if ($password != $password2) {
         $msg = _('Passwords do not match');
         $this->setRedirect($welcomeAuth, $msg, 'error');
         return false;
     }
     // If there was an error with registration, set the message and display form
     if (!$user->save()) {
         $this->setRedirect($welcomeAuth, JText::_($user->getError()), "error");
         return false;
     }
     //TODO: SEND MESSAGE TO USER
     //IF WAS INVITED DELETE INVITE
     if ($wasInvited) {
         $inviteTable->load((int) $inviteObject->ID);
         $inviteTable->state = 1;
         $inviteTable->acceptdate = date('Y-m-d H:i:s');
         if (!$inviteTable->store()) {
             JError::raiseError(TUIYO_SERVER_ERROR, _("Could not implement invite"));
             return false;
         }
     }
     // Everything went fine, set relevant message depending upon user activation state and display message
     if ($useractivation == 1) {
         $message = _('Your account has been created, An activation email has been sent to the e-mail provided');
     } else {
         $message = _('Your account has been created, no activation is required, You may now log-in');
     }
     $welcomeAuthL = JRoute::_(TUIYO_INDEX . '&amp;view=welcome&amp;do=auth', FALSE);
     $this->setRedirect($welcomeAuthL, $message, "notice");
 }
コード例 #24
0
ファイル: statistics.php プロジェクト: night-coder/ignite
 public function getUserComments($userID)
 {
     $tModel = TuiyoLoader::table('timeline');
     $tCount = $tModel->countUserActivities($userID, NULL, NULL, TRUE);
     return (int) $tCount;
 }
コード例 #25
0
ファイル: applications.php プロジェクト: night-coder/ignite
 public function getRecentlyUsed($userID, $count = 10)
 {
     $uTable = TuiyoLoader::table("userapps", true);
     $uApps = $uTable->getRecentlyUsed((int) $userID, $count);
     return (array) $uApps;
 }
コード例 #26
0
ファイル: profile.php プロジェクト: night-coder/ignite
 /**
  * TuiyoModelProfile::getUserBackgrounds()
  * Gets available user backgrounds;
  * @return
  */
 public function getUserBackgrounds()
 {
     $userData = $GLOBALS['API']->get("user");
     $resourceTable = TuiyoLoader::table("resources");
     $userWallpapers = $resourceTable->getUserWallpapers($userData->id);
     return (array) $userWallpapers;
 }
コード例 #27
0
ファイル: resources.php プロジェクト: night-coder/ignite
 /**
  * TuiyoTableResources::saveAvatarFile()
  * 
  * @param mixed $fileData
  * @return void
  */
 public function saveAvatarFile($fileData)
 {
     //1. Move the file to the actual Avatar Directory. i.e files/avatar/62/file.jpg
     $user = $GLOBALS["API"]->get("user", null);
     $fileCache = JPATH_CACHE . DS . basename($fileData['name']);
     $filePath = TUIYO_FILES . DS . "avatars" . DS . $user->id . DS;
     $newFilePath = $filePath . $this->fileName;
     //If we cannot create a folder
     if (!JFolder::exists($filePath)) {
         JFolder::create($filePath);
         JPath::setPermissions($filePath);
     }
     if (file_exists($newFilePath)) {
         JFile::delete($newFilePath);
         //Just delete the file
         //return true;
     }
     //If we cannot copy the file
     if (!JFile::copy($fileCache, $newFilePath)) {
         trigger_error("Could not copy the file", E_USER_ERROR);
         return false;
     }
     JFile::delete($fileCache);
     //2. Complete the File Information
     $this->filePath = JPath::clean($filePath);
     $this->url = $this->url . str_replace(array(JPATH_ROOT, DS), array("", "/"), $newFilePath);
     $this->dimension = json_encode(getimagesize($newFilePath));
     //3. Save the Object in the Database
     if (!$this->store()) {
         trigger_error($this->getError(), E_USER_ERROR);
         return false;
     }
     //print_R("stored okay"); die;
     //2. Update the User Table with the current user Avatar Details. I.e Avatar id!
     $thumbs = array("thumb200" => $this->createAvatarThumb(200), "thumb70" => $this->createAvatarThumb(70), "thumb35" => $this->createAvatarThumb(35));
     $paramsTable = TuiyoAPI::get("params");
     $paramsTable->loadParams("user.avatar", $this->userID);
     $query = "DELETE FROM #__tuiyo_params " . "\nWHERE userID='" . (int) $this->userID . "'\nAND application='user.avatar'";
     $this->_db->setQuery($query);
     $this->_db->query();
     $tableOfParams = TuiyoLoader::table("params");
     $tableOfParams->load(null);
     $tableOfParams->userID = $this->userID;
     $tableOfParams->data = json_encode($thumbs);
     $tableOfParams->application = "user.avatar";
     if (!$tableOfParams->store()) {
         trigger_error($thumbX->getError(), E_USER_ERROR);
         return false;
     }
     return true;
 }