Exemplo n.º 1
0
 public static function getInstance()
 {
     $suffix = JString::stristr(XiptHelperJomsocial::get_js_version(), 2.0) ? "Js20" : "Js18";
     $classname = "XiptFieldsTemplates" . JString::ucfirst($suffix);
     if (class_exists($classname, true) === false) {
         XiptError::raiseError(__CLASS__ . '.' . __LINE__, XiptText::_("{$className} : CLASS_NOT_FOUND"));
         return false;
     }
     $instance = new $classname();
     return $instance;
 }
Exemplo n.º 2
0
 function getName()
 {
     $name = $this->_name;
     if (empty($name)) {
         $r = null;
         if (!preg_match('/View(.*)/i', get_class($this), $r)) {
             XiptError::raiseError(__CLASS__ . '.' . __LINE__, "Can't get or parse class name.");
         }
         $name = strtolower($r[1]);
     }
     return $name;
 }
Exemplo n.º 3
0
 function unCopyXIPTFilesFromJomSocial()
 {
     $COMMUNITY_PATH_FRNTEND = JPATH_ROOT . DS . 'components' . DS . 'com_community';
     $targetFile = $COMMUNITY_PATH_FRNTEND . DS . 'libraries' . DS . 'fields' . DS . 'profiletypes.php';
     if (JFile::exists($targetFile)) {
         JFile::delete($targetFile) || XiptError::raiseError('XIPT-UNINSTALL-ERROR', 'Not able to restore backup:' . __LINE__);
     }
     $targetFile = $COMMUNITY_PATH_FRNTEND . DS . 'libraries' . DS . 'fields' . DS . 'templates.php';
     if (JFile::exists($targetFile)) {
         JFile::delete($targetFile) || XiptError::raiseError('XIPT-UNINSTALL-ERROR', 'Not able to restore backup : ' . __LINE__);
     }
     return;
 }
Exemplo n.º 4
0
 public function getAclObject($aclName)
 {
     $path = dirname(__FILE__) . DS . $aclName . DS . $aclName . '.php';
     if (!JFile::exists($path)) {
         XiptError::raiseError(__CLASS__ . '.' . __LINE__, sprintf(XiptText::_("INVALID_ACL_FILE"), $aclName));
         return false;
     }
     require_once $path;
     //$instance will comtain all addon object according to rule
     //Every rule will have different object
     static $instance = array();
     if (isset($instance[$aclName])) {
         return $instance[$aclName];
     }
     $instance[$aclName] = new $aclName();
     return $instance[$aclName];
 }
Exemplo n.º 5
0
 static function getInstance($name, $type, $prefix = 'Xipt', $refresh = false)
 {
     static $instance = array();
     //generate class name
     $className = JString::ucfirst($prefix) . JString::ucfirst($type) . JString::ucfirst($name);
     // Clean the name
     $className = preg_replace('/[^A-Z0-9_]/i', '', $className);
     //if already there is an object
     if ($refresh === false && isset($instance[$className])) {
         return $instance[$className];
     }
     //class_exists function checks if class exist,
     // and also try auto-load class if it can
     if (class_exists($className, true) === false) {
         XiptError::raiseError(__CLASS__ . '.' . __LINE__, sprintf(XiptText::_("CLASS_NOT_FOUND"), $className));
         return false;
     }
     //create new object, class must be autoloaded
     $instance[$className] = new $className();
     return $instance[$className];
 }
Exemplo n.º 6
0
 function save($data, $pk = null)
 {
     if (isset($data) === false || count($data) <= 0) {
         XiptError::raiseError(__CLASS__ . '.' . __LINE__, XiptText::_("NO_DATA_TO_SAVE_IN_USER_TABLE_KINDLY_RE-LOGIN_AND_RETRY_TO_SAVE_DATA"));
         return false;
     }
     //load the table row
     $table = $this->getTable();
     if (!$table) {
         XiptError::raiseError(__CLASS__ . '.' . __LINE__, sprintf(XiptText::_("TABLE_DOES_NOT_EXIST"), $table));
         return false;
     }
     $table->load($pk);
     //to clean cached data, reset record list
     $this->_recordlist = array();
     //bind, and then save
     if ($table->bind($data) && $table->store()) {
         return true;
     }
     //some error occured
     XiptError::raiseError(__CLASS__ . '.' . __LINE__, sprintf(XiptText::_("NOT_ABLE_TO_SAVE_DATA_IN_TABLE_PLEASE_RE-TRY"), $table));
     return false;
 }
Exemplo n.º 7
0
 /**
  * XITODO Method to order rows.
  */
 public function order($pk, $change)
 {
     XiptError::assert($pk, sprintf(XiptText::_("PRIMARY_KEY_DOES_NOT_EXIST"), $pk), XiptError::ERROR);
     //load the table row
     $table = $this->getTable();
     if (!$table) {
         return false;
     }
     //try to move
     if ($table->load($pk) && $table->move($change)) {
         return true;
     }
     //some error occured
     XiptError::raiseError(__CLASS__ . '.' . __LINE__, XiptText::_("NOT_ABLE_TO_LOAD_DATA"));
     return false;
 }
Exemplo n.º 8
0
 function copyLibraryFiles()
 {
     $XIPT_PATH_ADMIN = JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_xipt';
     $COMMUNITY_PATH_FRNTEND = JPATH_ROOT . DS . 'components' . DS . 'com_community';
     $sourceFile = $XIPT_PATH_ADMIN . DS . 'hacks' . DS . 'front_libraries_fields_profiletypes.php';
     $targetFile = $COMMUNITY_PATH_FRNTEND . DS . 'libraries' . DS . 'fields' . DS . 'profiletypes.php';
     JFile::copy($sourceFile, $targetFile) || XiptError::raiseError('INSTERR', "Not able to copy file " . $sourceFile . " to " . $targetFile);
     $sourceFile = $XIPT_PATH_ADMIN . DS . 'hacks' . DS . 'front_libraries_fields_templates.php';
     $targetFile = $COMMUNITY_PATH_FRNTEND . DS . 'libraries' . DS . 'fields' . DS . 'templates.php';
     JFile::copy($sourceFile, $targetFile) || XiptError::raiseError('INSTERR', "Not able to copy file " . $sourceFile . " to " . $targetFile);
     return;
 }
Exemplo n.º 9
0
define('DEFAULT_IMAGEWATERMRK', 'components' . DS . 'com_xipt' . DS . 'assets' . DS . 'images' . DS . 'demo_watermrk.png');
define('DEFAULT_IMAGEWATERMRK_THUMB', 'components' . DS . 'com_xipt' . DS . 'assets' . DS . 'images' . DS . 'demo_watermrk_thumb.png');
define('DEFAULT_DEMOAVATAR', 'components' . DS . 'com_xipt' . DS . 'assets' . DS . 'images' . DS . 'default_avatar.png');
define('DEFAULT_DEMOAVATAR_THUMB', 'components' . DS . 'com_xipt' . DS . 'assets' . DS . 'images' . DS . 'default_thumb.png');
//where to store profiletype avatars
define('PROFILETYPE_AVATAR_STORAGE_REFERENCE_PATH', 'images' . DS . 'profiletype');
define('PROFILETYPE_AVATAR_STORAGE_PATH', JPATH_ROOT . DS . PROFILETYPE_AVATAR_STORAGE_REFERENCE_PATH);
define('USER_AVATAR_BACKUP', JPATH_ROOT . DS . PROFILETYPE_AVATAR_STORAGE_REFERENCE_PATH . DS . 'useravatar');
if (JFolder::exists(PROFILETYPE_AVATAR_STORAGE_PATH) == false && JFolder::create(PROFILETYPE_AVATAR_STORAGE_PATH) === false) {
    XiptError::raiseError("XIPT-ERROR", "Folder [" . PROFILETYPE_AVATAR_STORAGE_PATH . "] does not exist. Even we are not able to create it. Please check file permission.");
    return false;
}
//if(JFolder::exists(PROFILETYPE_AVATAR_STORAGE_PATH))
//	chmod(PROFILETYPE_AVATAR_STORAGE_PATH, 0755);
if (JFolder::exists(USER_AVATAR_BACKUP) == false && JFolder::create(USER_AVATAR_BACKUP) === false) {
    XiptError::raiseError("XIPT-ERROR", "Folder [" . USER_AVATAR_BACKUP . "] does not exist. Even we are not able to create it. Please check file permission.");
    return false;
}
//if(JFolder::exists(USER_AVATAR_BACKUP))
//	chmod(USER_AVATAR_BACKUP, 0755);
// define constants for category of Profile Fields
define('PROFILE_FIELD_CATEGORY_ALLOWED', 0);
define('PROFILE_FIELD_CATEGORY_REQUIRED', 1);
define('PROFILE_FIELD_CATEGORY_VISIBLE', 2);
define('PROFILE_FIELD_CATEGORY_EDITABLE_AFTER_REG', 3);
define('PROFILE_FIELD_CATEGORY_EDITABLE_DURING_REG', 4);
define('PROFILE_FIELD_CATEGORY_ADVANCE_SEARCHABLE', 5);
//define constants for blocking display application according to owner,visitor and both
define('BLOCK_DISPLAY_APP_OF_OWNER', 0);
define('BLOCK_DISPLAY_APP_OF_VISITOR', 1);
define('BLOCK_DISPLAY_APP_OF_BOTH', 2);
Exemplo n.º 10
0
 /**
  * Get structure of table from db table
  */
 public function getColumns()
 {
     if (isset($this->_columns)) {
         return $this->_columns;
     }
     $tableName = $this->getTableName();
     if (XiptHelperTable::isTableExist($tableName) === FALSE) {
         return XiptError::raiseError(__CLASS__ . '.' . __LINE__, XiptText::_("Table {$this->_tbl} DOES_NOT_EXIST"));
     }
     $fields = $this->_db->getTableFields($tableName);
     $this->_columns = $fields[$tableName];
     return $this->_columns;
 }
Exemplo n.º 11
0
/**
* @Copyright Ready Bytes Software Labs Pvt. Ltd. (C) 2010- author-Team Joomlaxi
* @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
*@TODO : Include all helper files or other files in one common file and include that file
**/
// no direct access
if (!defined('_JEXEC')) {
    die('Restricted access');
}
// add include files
require_once JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_xipt' . DS . 'includes.php';
// check for jom social supported version and show message
if (!XiptHelperJomsocial::isSupportedJS()) {
    $msg = "ERROR : The JomSocial Current Version used by you is not supported for ProfileTypes.";
    JFactory::getApplication()->enqueueMessage($msg);
}
$controller = JRequest::getCmd('view', 'cpanel');
$controller = JString::strtolower($controller);
$class = 'XiptController' . JString::ucfirst($controller);
// Test if the object really exists in the current context
if (!class_exists($class, true)) {
    XiptError::raiseError(__CLASS__ . '.' . __LINE__, sprintf(XiptText_("INVALID_CONTROLLER_OBJECT_CLASS_DEFINITION_DOES_NOT_EXISTS_IN_THIS_CONTEXT"), $class));
}
$controller = new $class();
// Perform the Request task
$task = JRequest::getCmd('task', 'display');
// Task's are methods of the controller. Perform the Request task
$controller->execute($task);
// Redirect if set by the controller
$controller->redirect();
Exemplo n.º 12
0
 function createImageWatermark($path, $filename)
 {
     XiptError::assert(!empty($path), XiptText::_("PATH_IS_EMPTY"), XiptError::ERROR);
     XiptError::assert(!empty($filename), XiptText::_("FILE_IS_EMPTY"), XiptError::ERROR);
     //here check if folder exist or not. if not then create it.
     if (JFolder::exists($path) == false && JFolder::create($path) === false) {
         XiptError::raiseError(__CLASS__ . '.' . __LINE__, sprintf(XiptText::_("FOLDER_DOES_NOT_EXIST"), $path));
         return false;
     }
     $filename = $filename . ".png";
     $filepath = $path . "/" . $filename;
     //create an image identifier from path
     $img = $this->load($this->imgname);
     if ($img == false) {
         return false;
     }
     $img_width = imagesx($img);
     $img_height = imagesy($img);
     //create a blank transparent image with the
     // height and width of the watermark
     $new_image = $this->imageCreateTransparent($this->width, $this->height);
     // resize $img to watermark height and width
     //copy it to $new_image
     imagecopyresampled($new_image, $img, 0, 0, 0, 0, $this->width, $this->height, $img_width, $img_height);
     // create an png image
     $result = imagepng($new_image, $filepath);
     chmod($filepath, 0744);
     imagedestroy($new_image);
     // if file creation is successfull return filename , else false
     return $result ? $filename : false;
 }
Exemplo n.º 13
0
 function getUserData($userid, $what = 'PROFILETYPE')
 {
     $results = array();
     switch ($what) {
         case 'PROFILETYPE':
             if ($userid == 0) {
                 return XiptFactory::getSettings('guestProfiletypeID', XiptFactory::getSettings('defaultProfiletypeID', 0));
             }
             $getMe = PROFILETYPE_FIELD_IN_USER_TABLE;
             $defaultValue = XiptLibProfiletypes::getDefaultProfiletype();
             break;
         case 'TEMPLATE':
             $getMe = TEMPLATE_FIELD_IN_USER_TABLE;
             $allTemplates = XiptHelperJomsocial::getTemplatesList();
             $pID = XiptLibProfiletypes::getUserData($userid, 'PROFILETYPE');
             $defaultValue = XiptLibProfiletypes::getProfileTypeData($pID, 'template');
             //else get system template
             if (in_array($defaultValue, $allTemplates) === false) {
                 $defaultValue = XiptLibProfiletypes::getDefaultTemplate();
             }
             break;
         default:
             XiptError::raiseError('XIPT-SYSTEM-ERROR', 'XIPT System Error');
     }
     $results = XiptFactory::getInstance('users', 'model')->loadRecords(0);
     // not a valid result OR value not set
     if (!$results || isset($results[$userid]) == false) {
         return $defaultValue;
     }
     $what = strtolower($what);
     return $results[$userid]->{$what};
 }
Exemplo n.º 14
0
 function multidobool($task = 'enable', $cids = array(0))
 {
     $task = JRequest::getVar('task', $task);
     $offpattern = '/^switchOff/';
     $onpattern = '/^switchOn/';
     if (preg_match($onpattern, $task)) {
         $switch = false;
         //$columninfo = str_split($task,strlen('switchOn'));
         $columninfo = explode('switchOn', $task);
         $column = array_key_exists(1, $columninfo) ? $columninfo[1] : '';
         $value = 1;
     } else {
         if (preg_match($offpattern, $task)) {
             $switch = false;
             //$columninfo = str_split($task,strlen('switchOff'));
             $columninfo = explode('switchOff', $task);
             $column = array_key_exists(1, $columninfo) ? $columninfo[1] : '';
             $value = 0;
         } else {
             XiptError::assert(0);
         }
     }
     $cids = JRequest::getVar('cid', $cids, 'post', 'array');
     foreach ($cids as $cid) {
         if (!$this->_doBool($column, $value, $cid)) {
             XiptError::raiseError(__CLASS__ . '.' . __LINE__, XiptText::_("ERROR_IN_REORDERING_ITEMS"));
         }
     }
     //redirect now
     $this->setRedirect(XiptRoute::_("index.php?option=com_" . JString::strtolower($this->getPrefix()) . "&view={$this->getName()}"), sprintf(XiptText::_($task . '.MSG'), $cids));
     return false;
 }
Exemplo n.º 15
0
 function uploadAndSetImage($file, $id, $what)
 {
     $mainframe =& JFactory::getApplication();
     CFactory::load('helpers', 'image');
     $config = CFactory::getConfig();
     $uploadLimit = (double) $config->get('maxuploadsize');
     $uploadLimit = $uploadLimit * 1024 * 1024;
     // @rule: Limit image size based on the maximum upload allowed.
     if (filesize($file['tmp_name']) > $uploadLimit) {
         $mainframe->enqueueMessage(XiptText::_('IMAGE_FILE_SIZE_EXCEEDED'), 'error');
         $mainframe->redirect(CRoute::_('index.php?option=com_xipt&view=profiletypes&task=edit&id=' . $id, false));
     }
     if (!cValidImage($file['tmp_name'])) {
         $mainframe->enqueueMessage(XiptText::_('IMAGE_FILE_NOT_SUPPORTED'), 'error');
     } else {
         switch ($what) {
             case 'avatar':
                 $imageMaxWidth = AVATAR_WIDTH;
                 $thumbWidth = AVATAR_WIDTH_THUMB;
                 $thumbHeight = AVATAR_HEIGHT_THUMB;
                 $imgPrefix = 'avatar_';
                 break;
             case 'watermark':
                 $imageMaxWidth = WATERMARK_WIDTH;
                 $thumbWidth = WATERMARK_WIDTH_THUMB;
                 $thumbHeight = WATERMARK_HEIGHT_THUMB;
                 $imgPrefix = 'watermark_';
                 break;
         }
         $storage = PROFILETYPE_AVATAR_STORAGE_PATH;
         $storageImage = $storage . DS . $imgPrefix . $id . cImageTypeToExt($file['type']);
         $storageThumbnail = $storage . DS . $imgPrefix . $id . '_thumb' . cImageTypeToExt($file['type']);
         $image = PROFILETYPE_AVATAR_STORAGE_REFERENCE_PATH . DS . $imgPrefix . $id . cImageTypeToExt($file['type']);
         //$thumbnail			= PROFILETYPE_AVATAR_STORAGE_REFERENCE_PATH . $imgPrefix . $id.'_thumb' . cImageTypeToExt( $file['type'] );
         //here check if folder exist or not. if not then create it.
         if (JFolder::exists($storage) == false) {
             JFolder::create($storage);
         }
         // Only resize when the width exceeds the max.
         if (!cImageResizePropotional($file['tmp_name'], $storageImage, $file['type'], $imageMaxWidth)) {
             $mainframe->enqueueMessage(XiptText::sprintf('COM_XIPT_ERROR_MOVING_UPLOADED_FILE', $storageImage), 'error');
         }
         // Generate thumbnail
         if (!cImageCreateThumb($file['tmp_name'], $storageThumbnail, $file['type'], $thumbWidth, $thumbHeight)) {
             $mainframe->enqueueMessage(XiptText::sprintf('COM_XIPT_ERROR_MOVING_UPLOADED_FILE', $storageThumbnail), 'error');
         }
         $oldFile = XiptLibProfiletypes::getProfiletypeData($id, $what);
         // If old file is default_thumb or default, we should not remove it.
         if (!Jstring::stristr($oldFile, DEFAULT_AVATAR) && !Jstring::stristr($oldFile, DEFAULT_AVATAR_THUMB) && $oldFile != $image && $oldFile != '') {
             // File exists, try to remove old files first.
             $oldFile = JString::str_ireplace('/', DS, $oldFile);
             //only delete when required
             if (JFile::exists($oldFile)) {
                 JFile::delete($oldFile);
             }
         }
         //here due to extension mismatch we can break the functionality of avatar
         if ($what === 'avatar') {
             /* No need to update thumb here , script will update both avatar and thumb */
             //$newThumb   = XiptHelperImage::getThumbAvatarFromFull($newAvatar);
             $oldAvatar = XiptLibProfiletypes::getProfiletypeData($id, 'avatar');
             $allUsers = XiptLibProfiletypes::getAllUsers($id);
             if ($allUsers) {
                 $filter[] = 'avatar';
                 $newData['avatar'] = $image;
                 $oldData['avatar'] = $oldAvatar;
                 foreach ($allUsers as $userid) {
                     XiptLibProfiletypes::updateUserProfiletypeFilteredData($userid, $filter, $oldData, $newData);
                 }
             }
         }
         //now update profiletype with new avatar or watermark
         if (!XiptFactory::getInstance('profiletypes', 'model')->save(array($what => XiptHelperUtils::getUrlpathFromFilePath($image)), $id)) {
             XiptError::raiseError(__CLASS__ . '.' . __LINE__, XiptText::_("ERROR_IN_DATABASE"));
         }
     }
 }
Exemplo n.º 16
0
 function updateCommunityCustomField($userId, $value, $what = '')
 {
     //ensure we are calling it for correct field
     XiptError::assert($what == PROFILETYPE_CUSTOM_FIELD_CODE || $what == TEMPLATE_CUSTOM_FIELD_CODE, XiptText::_("CUSTOM_FIELD_DOES_NOT_EXIST"), XiptError::ERROR);
     // find the profiletype or template field
     // dont patch up the database.
     $res = XiptHelperJomsocial::getFieldId($what);
     // skip these calls from backend
     XiptError::assert($res);
     $field_id = $res;
     //if row does not exist
     $query = new XiptQuery();
     $res = $query->select('*')->from('#__community_fields_values')->where(" user_id = {$userId} ", 'AND')->where(" field_id = {$field_id} ")->dbLoadQuery()->loadObject();
     $db = JFactory::getDBO();
     //record does not exist, insert it
     if (!$res) {
         $res = new stdClass();
         $res->user_id = $userId;
         $res->field_id = $field_id;
         $res->value = $value;
         $db->insertObject('#__community_fields_values', $res, 'id');
         if ($db->getErrorNum()) {
             XiptError::raiseError(__CLASS__ . '.' . __LINE__, $db->stderr());
         }
         return true;
     }
     // change the type
     $res->user_id = $userId;
     $res->field_id = $field_id;
     $res->value = $value;
     $db->updateObject('#__community_fields_values', $res, 'id');
     if ($db->getErrorNum()) {
         XiptError::raiseError(__CLASS__ . '.' . __LINE__, $db->stderr());
     }
     return true;
 }