Example #1
0
 /**
  * Constructor
  * @param	object    $object   reference to targetobject (@link icms_ipf_Object)
  * @param	string    $key      the form name
  */
 public function __construct($object, $key)
 {
     global $icmsConfig;
     parent::__construct($object->vars[$key]['form_caption'], $key, $object->getVar($key, 'e'));
     $control = $object->getControl($key);
     $editor_handler = icms_plugins_EditorHandler::getInstance('source');
     $this->_editor =& $editor_handler->get($icmsConfig['sourceeditor_default'], array('name' => $key, 'value' => $object->getVar($key, 'e'), 'language' => isset($control['language']) ? $control['language'] : _LANGCODE, 'width' => isset($control['width']) ? $control['width'] : '100%', 'height' => isset($control['height']) ? $control['height'] : '400px', 'syntax' => isset($control['syntax']) ? $control['syntax'] : 'php'));
 }
Example #2
0
 /**
  * Store the parsed message in database
  * @access public
  * @param object $msg {@link xhelpParsedMsg} object Message to add
  * @param object $user {@link xoopsUser} object User that submitted message
  * @param object $mbox {@link xhelpDepartmentMailBox} object. Originating Mailbox for message
  * @return mixed Returns {@link xhelpTicket} object if new ticket, {@link xhelpResponses} object if a response, and false if unable to save.
  */
 function &storeMsg(&$msg, &$user, &$mbox, &$errors)
 {
     //Remove any previous error messages
     $this->clearErrors();
     $type = $msg->getMsgType();
     switch ($type) {
         case _XHELP_MSGTYPE_TICKET:
             $obj =& $this->_hTicket->create();
             $obj->setVar('uid', $user->getVar('uid'));
             $obj->setVar('subject', $msg->getSubject());
             $obj->setVar('description', $msg->getMsg());
             $obj->setVar('department', $mbox->getVar('departmentid'));
             $obj->setVar('priority', $mbox->getVar('priority'));
             $obj->setVar('posted', time());
             $obj->setVar('serverid', $mbox->getVar('id'));
             $obj->setVar('userIP', 'via Email');
             $obj->setVar('email', $user->getVar('email'));
             if (!($status = xhelpGetMeta("default_status"))) {
                 xhelpSetMeta("default_status", "1");
                 $status = 1;
             }
             $obj->setVar('status', $status);
             $obj->createEmailHash($msg->getEmail());
             if ($this->_hTicket->insert($obj)) {
                 $obj->addSubmitter($user->getVar('email'), $user->getVar('uid'));
                 $this->_saveAttachments($msg, $obj->getVar('id'));
                 $errors = $this->_getErrors();
                 return array($obj);
             }
             break;
         case _XHELP_MSGTYPE_RESPONSE:
             if (!($ticket = $this->_hTicket->getTicketByHash($msg->getHash()))) {
                 $this->_setError(_XHELP_RESPONSE_NO_TICKET);
                 return false;
             }
             if ($msg->getEmail() != $ticket->getVar('email')) {
                 $this->_setError(sprintf(_XHELP_MISMATCH_EMAIL, $msg->getEmail(), $ticket->getVar('email')));
                 return false;
             }
             $obj = $this->_hResponse->create();
             $obj->setVar('ticketid', $ticket->getVar('id'));
             $obj->setVar('uid', $user->getVar('uid'));
             $obj->setVar('message', $msg->getMsg());
             $obj->setVar('updateTime', time());
             $obj->setVar('userIP', 'via Email');
             if ($this->_hResponse->insert($obj)) {
                 $this->_saveAttachments($msg, $ticket->getVar('id'), $obj->getVar('id'));
                 $ticket->setVar('lastUpdated', time());
                 $this->_hTicket->insert($ticket);
                 $errors = $this->_getErrors();
                 return array($ticket, $obj);
             }
             break;
         default:
             //Sanity Check, should never get here
     }
     return false;
 }
Example #3
0
 /**
  * Constructor
  * @param	object    $object   reference to targetobject (@link icms_ipf_Object)
  * @param	string    $key      the form name
  */
 public function __construct($object, $key)
 {
     $var = $object->vars[$key];
     $control = $object->getControl($key);
     $object_imageurl = $object->getImageDir();
     parent::__construct($var['form_caption'], ' ');
     if (isset($objectArray['image'])) {
         $objectArray['image'] = str_replace('{ICMS_URL}', ICMS_URL, $objectArray['image']);
     }
     if ($object->getVar($key, 'e') != '' && (substr($object->getVar($key, 'e'), 0, 4) == 'http' || substr($object->getVar($key, 'e'), 0, 10) == '{ICMS_URL}')) {
         $this->addElement(new icms_form_elements_Label('', "<img src='" . str_replace('{ICMS_URL}', ICMS_URL, $object->getVar($key, 'e')) . "' alt='' /><br/><br/>"));
     } elseif ($object->getVar($key, 'e') != '') {
         $this->addElement(new icms_form_elements_Label('', "<a rel='lightbox' title='" . $object_imageurl . $object->getVar($key, 'e') . "' href='" . $object_imageurl . $object->getVar($key, 'e') . "' ><img class='acp_object_imageurl' src='" . $object_imageurl . $object->getVar($key, 'e') . "' alt='" . $object_imageurl . $object->getVar($key, 'e') . "' height='150' /></a><br/><br/>"));
     }
     $this->addElement(new icms_ipf_form_elements_Fileupload($object, $key));
     if (!isset($control['nourl']) || !$control['nourl']) {
         $this->addElement(new icms_form_elements_Label('<div style="padding-top: 8px; font-size: 80%;">' . _CO_ICMS_URL_FILE_DSC . '</div>', ''));
         $this->addElement(new icms_form_elements_Label('', '<br />' . _CO_ICMS_URL_FILE));
         $this->addElement(new icms_form_elements_Text('', 'url_' . $key, 50, 500));
     }
     if (!$object->isNew()) {
         $this->addElement(new icms_form_elements_Label('', '<br /><br />'));
         $delete_check = new icms_form_elements_Checkbox('', 'delete_' . $key);
         $delete_check->addOption(1, '<span style="color:red;">' . _CO_ICMS_DELETE . '</span>');
         $this->addElement($delete_check);
     }
 }
Example #4
0
 /**
  * Constructor
  * @param	object    $object   reference to targetobject (@link IcmsPersistableObject)
  * @param	string    $key      the form name
  */
 function __construct($object, $key)
 {
     $var = $object->vars[$key];
     $control = $object->controls[$key];
     parent::__construct($var['title'], '<br /><br />', $key . '_signature_tray');
     $signature_textarea = new Xmf_Form_Element_Textarea_Dhtml('', $key, $object->getVar($key, 'e'));
     $this->addElement($signature_textarea);
     $attach_checkbox = new Xmf_Form_Element_Checkbox('', 'attachsig', $object->getVar('attachsig', 'e'));
     $attach_checkbox->addOption(1, _US_SHOWSIG);
     $this->addElement($attach_checkbox);
 }
Example #5
0
 /**
  * Constructor
  * @param	object    $object   reference to targetobject (@link icms_ipf_Object)
  * @param	string    $key      the form name
  */
 public function __construct($object, $key)
 {
     $var = $object->vars[$key];
     parent::__construct($var['form_caption'], '<br /><br />', $key . '_signature_tray');
     icms_loadLanguageFile('core', 'user');
     $signature_textarea = new icms_form_elements_Dhtmltextarea('', $key, $object->getVar($key, 'e'));
     $this->addElement($signature_textarea);
     $attach_checkbox = new icms_form_elements_Checkbox('', 'attachsig', $object->getVar('attachsig', 'e'));
     $attach_checkbox->addOption(1, _US_SHOWSIG);
     $this->addElement($attach_checkbox);
 }
Example #6
0
 /**
  * Constructor
  * @param	object    $object   reference to targetobject (@link icms_ipf_Object)
  * @param	string    $key      the form name
  */
 public function __construct($object, $key)
 {
     $var = $object->vars[$key];
     parent::__construct($var['form_caption'], ' ', 'options_tray');
     $func = $object->getVar('edit_func');
     require_once ICMS_ROOT_PATH . "/modules/" . $object->handler->getModuleDirname($object->getVar('mid', 'e')) . "/blocks/" . $object->getVar('func_file');
     icms_loadLanguageFile($object->handler->getModuleDirname($object->getVar('mid', 'e')), 'blocks');
     if (!function_exists($func)) {
         return;
     }
     $visible_label = new icms_form_elements_Label('', $func(explode('|', $object->getVar('options'))));
     $this->addElement($visible_label);
 }
Example #7
0
 /**
  * Constructor
  * @param	object    $object   reference to targetobject (@link icms_ipf_Object)
  * @param	string    $key      the form name
  */
 public function __construct($object, $key)
 {
     icms_loadLanguageFile('system', 'blocksadmin', TRUE);
     parent::__construct(_AM_VISIBLEIN, ' ', $key . '_visiblein_tray');
     $visible_label = new icms_form_elements_Label('', '<select name="visiblein[]" id="visiblein[]" multiple="multiple" size="10">' . $this->getPageSelOptions($object->getVar('visiblein')) . '</select>');
     $this->addElement($visible_label);
 }
Example #8
0
 /**
  * Constructor
  * @param   object    $title   the caption of the form
  * @param   string    $key            the key
  * @param   object    $object         reference to targetobject (@todo, which object will be passed here?)
  */
 function __construct($title, $key, $object)
 {
     parent::__construct($title, '&nbsp;');
     $this->addElement(new Xmf_Form_Element_Label('', '<br/>' . _FORM_XMF_URLLINK_URL));
     $this->addElement(new Xmf_Object_Form_Element_Text($object, 'url_' . $key));
     $this->addElement(new Xmf_Form_Element_Label('', '<br/>' . _FORM_XMF_CAPTION));
     $this->addElement(new Xmf_Object_Form_Element_Text($object, 'caption_' . $key));
     $this->addElement(new Xmf_Form_Element_Label('', '<br/>' . _FORM_XMF_DESC . '<br/>'));
     $this->addElement(new Xmf_Form_Element_Textarea('', 'desc_' . $key, $object->getVar('description')));
     $this->addElement(new Xmf_Form_Element_Label('', '<br/>' . _FORM_XMF_URLLINK_TARGET));
     $targ_val = $object->getVar('target');
     $targetRadio = new Xmf_Form_Element_Radio('', 'target_' . $key, $targ_val != '' ? $targ_val : '_blank');
     $control = $object->getControl('target');
     $targetRadio->addOptionArray($control['options']);
     $this->addElement($targetRadio);
 }
 /**
  * add module related config variable array
  *
  * @param string $module Module name
  * @param array data Associative array
  */
 public function addConfigVar($module, &$data)
 {
     if (null !== $this->config->getVar($module)) {
         $this->config->setVar($module, $data);
         return true;
     }
     throw new JapaInitException('Module config array exists: ' . $module);
 }
Example #10
0
 /**
  * Constructor
  * @param	object    $object   reference to targetobject (@link IcmsPersistableObject)
  * @param	string    $key      the form name
  */
 function __construct($object, $key)
 {
     $var = $object->vars[$key];
     $control = $object->controls[$key];
     $form_maxlength = isset($control['maxlength']) ? $control['maxlength'] : (isset($var['maxlength']) ? $var['maxlength'] : 255);
     $form_size = isset($control['size']) ? $control['size'] : 50;
     parent::__construct($var['title'], $key, $form_size, $form_maxlength, $object->getVar($key, 'e'));
 }
Example #11
0
 /**
  * Constructor
  * @param	object    $object   reference to targetobject (@link IcmsPersistableObject)
  * @param	string    $key      the form name
  */
 function __construct($object, $key)
 {
     $var = $object->vars[$key];
     $control = $object->controls[$key];
     $all = isset($control['all']) ? true : false;
     parent::__construct($var['title'], $key, $object->getVar($key, 'e'));
     if ($all) {
         $this->addOption('all', _ALL);
     }
 }
 /**
  * Get a list of the common constants required for notifications
  *
  * @return array $tags
  *
  * @access private
  */
 function &_getCommonTplVars()
 {
     global $xoopsConfig;
     $tags = array();
     $tags['X_MODULE'] = $this->_module->getVar('name');
     $tags['X_SITEURL'] = XHELP_SITE_URL;
     $tags['X_SITENAME'] = $xoopsConfig['sitename'];
     $tags['X_ADMINMAIL'] = $xoopsConfig['adminmail'];
     $tags['X_MODULE_URL'] = XHELP_BASE_URL . '/';
     return $tags;
 }
Example #13
0
 /**
  * Constructor
  * @param	object    $object   reference to targetobject (@link IcmsPersistableObject)
  * @param	string    $key      the form name
  */
 function __construct($object, $key)
 {
     $var = $object->vars[$key];
     $object_imageurl = $object->getImageDir();
     parent::__construct($var['title'], ' ');
     if (isset($objectArray['image'])) {
         $objectArray['image'] = str_replace('{ICMS_URL}', ICMS_URL, $objectArray['image']);
     }
     if ($object->getVar($key, 'e') != '' && (substr($object->getVar($key, 'e'), 0, 4) == 'http' || substr($object->getVar($key, 'e'), 0, 11) == '{XOOPS_URL}')) {
         $this->addElement(new Xmf_Form_Element_Label('', "<img src='" . str_replace('{XOOPS_URL}', XOOPS_URL, $object->getVar($key, 'e')) . "' alt='' /><br/><br/>"));
     } else {
         if ($object->getVar($key, 'e') != '') {
             $this->addElement(new Xmf_Form_Element_Label('', "<img src='" . $object_imageurl . $object->getVar($key, 'e') . "' alt='' /><br/><br/>"));
         }
     }
     $this->addElement(new Xmf_Object_Form_Element_Upload_File($object, $key));
     $this->addElement(new Xmf_Form_Element_Label('<div style="padding-top: 8px; font-size: 80%;">' . _FORM_XMF_URL_FILE_DSC . '</div>', ''));
     $this->addElement(new Xmf_Form_Element_Label('', '<br />' . _FORM_XMF_URL_FILE));
     $this->addElement(new Xmf_Form_Element_Text('', 'url_' . $key, 50, 500));
     if (!$object->isNew()) {
         $this->addElement(new Xmf_Form_Element_Label('', '<br /><br />'));
         $delete_check = new Xmf_Form_Element_Checkbox_Check('', 'delete_' . $key);
         $delete_check->addOption(1, '<span style="color:red;">' . _FORM_XMF_DELETE . '</span>');
         $this->addElement($delete_check);
     }
 }
Example #14
0
 /**
  * Get a config
  *
  * @param	string  $title   caption of the form element
  * @param	string  $key            key of the variable in the passed object
  * @param	object  $object         the passed object (target object) (@todo which object)
  */
 function __construct($title, $key, $object)
 {
     parent::__construct($title, '&nbsp;');
     if ($object->getVar('url') != '') {
         $caption = $object->getVar('caption') != '' ? $object->getVar('caption') : $object->getVar('url');
         $this->addElement(new Xmf_Form_Element_Label('', _FORM_XMF_CURRENT_FILE . "<a href='" . str_replace('{ICMS_URL}', ICMS_URL, $object->getVar('url')) . "' target='_blank' >" . $caption . "</a><br/><br/>"));
         //$this->addElement( new XoopsFormLabel( '', "<br/><a href = '".SMARTOBJECT_URL."admin/file.php?op=del&fileid=".$object->id()."'>"._FORM_XUUPS_DELETE_FILE."</a>"));
     }
     if ($object->isNew()) {
         $this->addElement(new Xmf_Object_Form_Element_Upload_File($object, $key));
         $this->addElement(new Xmf_Form_Element_Label('', '<br/><br/><small>' . _FORM_XMF_URL_FILE_DSC . '</small>'));
         $this->addElement(new Xmf_Form_Element_Label('', '<br/>' . _FORM_XMF_URL_FILE));
         $this->addElement(new Xmf_Object_Form_Element_Text($object, 'url_' . $key));
     }
     $this->addElement(new Xmf_Form_Element_Label('', '<br/>' . _FORM_XMF_CAPTION));
     $this->addElement(new Xmf_Object_Form_Element_Text($object, 'caption_' . $key));
     $this->addElement(new Xmf_Form_Element_Label('', '<br/>' . _FORM_XMF_DESC . '<br/>'));
     $this->addElement(new Xmf_Form_Element_Textarea('', 'desc_' . $key, $object->getVar('description')));
     if (!$object->isNew()) {
         $this->addElement(new Xmf_Form_Element_Label('', '<br/>' . _FORM_XMF_CHANGE_FILE));
         $this->addElement(new Xmf_Object_Form_Element_Upload_File($object, $key));
         $this->addElement(new Xmf_Form_Element_Label('', '<br/><br/><small>' . _FORM_XMF_URL_FILE_DSC . '</small>'));
         $this->addElement(new Xmf_Form_Element_Label('', '<br/>' . _FORM_XMF_URL_FILE));
         $this->addElement(new Xmf_Object_Form_Element_Text($object, 'url_' . $key));
     }
 }
Example #15
0
 /**
  * Constructor
  * @param	object    $object   reference to targetobject (@link IcmsPersistableObject)
  * @param	string    $key      the form name
  */
 function __construct($object, $key)
 {
     $var = $object->vars[$key];
     $timearray = array();
     for ($i = 0; $i < 24; $i++) {
         for ($j = 0; $j < 60; $j = $j + 10) {
             $key_t = $i * 3600 + $j * 60;
             $timearray[$key_t] = $j != 0 ? $i . ':' . $j : $i . ':0' . $j;
         }
     }
     ksort($timearray);
     parent::__construct($var['title'], $key, $object->getVar($key, 'e'));
     $this->addOptionArray($timearray);
 }
Example #16
0
 /**
  * Constructor
  * @param	object    $object   reference to targetobject (@link icms_ipf_Object)
  * @param	string    $key      the form name
  */
 public function __construct($object, $key)
 {
     $var = $object->vars[$key];
     $size = isset($var['size']) ? $var['size'] : ($this->_multiple ? 5 : 1);
     parent::__construct($var['form_caption'], $key, $object->getVar($key, 'e'), $size, $this->_multiple);
     $sql = "SELECT uid, uname FROM " . icms::$xoopsDB->prefix("users") . " ORDER BY uname ASC";
     $result = icms::$xoopsDB->query($sql);
     if ($result) {
         while ($myrow = icms::$xoopsDB->fetchArray($result)) {
             $uArray[$myrow["uid"]] = $myrow["uname"];
         }
     }
     $this->addOptionArray($uArray);
 }
Example #17
0
 /**
  * Constructor
  * @param	object    $object   reference to targetobject (@link icms_ipf_Object)
  * @param	string    $key      the form name
  */
 public function __construct($object, $key)
 {
     if (isset($object->vars[$key])) {
         $var = $object->vars[$key];
     }
     if (isset($object->controls[$key])) {
         $control = $object->controls[$key];
         $form_maxlength = isset($control['maxlength']) ? $control['maxlength'] : (isset($var['maxlength']) ? $var['maxlength'] : 255);
         $form_size = isset($control['size']) ? $control['size'] : 50;
     } else {
         $form_maxlength = 255;
         $form_size = 50;
     }
     parent::__construct(isset($var['form_caption']) ? $var['form_caption'] : "", $key, $form_size, $form_maxlength, $object->getVar($key, 'e'));
 }
 /**
  * Send init call to all modules
  *
  */
 private function registerModulesFolders()
 {
     // A "common" base module must be present
     //
     $base_module = $this->config->getVar('base_module');
     $last_module = $this->config->getVar('last_module');
     if ($base_module != false) {
         $mod_common = JAPA_MODULES_DIR . $base_module;
         if (file_exists($mod_common)) {
             // register this module folder
             $this->model->init($base_module);
         } else {
             throw new JapaInitException("The module '{$mod_common}'  must be installed!");
         }
     }
     // get exsisting module folders
     //
     $tmp_directory = dir(JAPA_MODULES_DIR);
     while (false != ($tmp_dirname = $tmp_directory->read())) {
         if ($tmp_dirname == '.' || $tmp_dirname == '..' || $tmp_dirname == '.svn') {
             continue;
         }
         // dont register base module here
         if ($tmp_dirname == $base_module) {
             continue;
         }
         // dont register last module here
         if ($tmp_dirname == $last_module) {
             continue;
         }
         if (@is_dir(JAPA_MODULES_DIR . $tmp_dirname)) {
             $this->model->init($tmp_dirname);
         }
     }
     $tmp_directory->close();
     // register last module
     if ($last_module != false) {
         $mod_init = JAPA_MODULES_DIR . $last_module;
         if (@is_dir($mod_init)) {
             $this->model->init($last_module);
         } else {
             throw new JapaInitException("The 'last' module folder '{$mod_init}' is missing!");
         }
     }
 }
Example #19
0
 /**
  * Constructor
  * @param	object    $object   reference to targetobject (@link icms_ipf_Object)
  * @param	string    $key      the form name
  */
 public function __construct($object, $key)
 {
     $var = $object->vars[$key];
     $control = $object->getControl($key);
     if (isset($control['delimeter'])) {
         $this->_delimeter = $control['delimeter'];
     }
     parent::__construct($var['form_caption'], $key, $object->getVar($key, 'e'), $this->_delimeter);
     // Adding the options inside this Radio element
     // If the custom method is not from a module, than it's from the core
     if (isset($control['options'])) {
         $this->addOptionArray($control['options']);
     } else {
         // let's find out if the method we need to call comes from an already defined object
         if (isset($control['object'])) {
             if (method_exists($control['object'], $control['method'])) {
                 if ($option_array = $control['object']->{$control}['method']()) {
                     // Adding the options array to the Radio element
                     $this->addOptionArray($option_array);
                 }
             }
         } else {
             // finding the itemHandler; if none, let's take the itemHandler of the $object
             if (isset($control['itemHandler'])) {
                 if (!$control['module']) {
                     // Creating the specified core object handler
                     $control_handler = icms::handler($control['itemHandler']);
                 } else {
                     $control_handler =& icms_getModuleHandler($control['itemHandler'], $control['module']);
                 }
             } else {
                 $control_handler =& $object->handler;
             }
             // Checking if the specified method exists
             if (method_exists($control_handler, $control['method'])) {
                 // TODO : How could I pass the parameters in the following call ...
                 if ($option_array = $control_handler->{$control}['method']()) {
                     // Adding the options array to the Radio element
                     $this->addOptionArray($option_array);
                 }
             }
         }
     }
 }
Example #20
0
 /**
  * Constructor
  * @param	object    $object   reference to targetobject (@link icms_ipf_Object)
  * @param	string    $key      the form name
  */
 public function __construct($object, $key)
 {
     $var = $object->vars[$key];
     $size = isset($var['size']) ? $var['size'] : ($this->_multiple ? 5 : 1);
     // Adding the options inside this SelectBox
     // If the custom method is not from a module, than it's from the core
     $control = $object->getControl($key);
     $value = isset($control['value']) ? $control['value'] : $object->getVar($key, 'e');
     parent::__construct($var['form_caption'], $key, $value, $size, $this->_multiple);
     if (isset($control['options'])) {
         $this->addOptionArray($control['options']);
     } else {
         // let's find if the method we need to call comes from an already defined object
         if (isset($control['object'])) {
             if (method_exists($control['object'], $control['method'])) {
                 if ($option_array = $control['object']->{$control}['method']()) {
                     // Adding the options array to the select element
                     $this->addOptionArray($option_array);
                 }
             }
         } else {
             // finding the itemHandler; if none, let's take the itemHandler of the $object
             if (isset($control['itemHandler'])) {
                 if (!isset($control['module'])) {
                     // Creating the specified core object handler
                     $control_handler = icms::handler($control['itemHandler']);
                 } else {
                     $control_handler =& icms_getModuleHandler($control['itemHandler'], $control['module']);
                 }
             } else {
                 $control_handler =& $object->handler;
             }
             // Checking if the specified method exists
             if (method_exists($control_handler, $control['method'])) {
                 $option_array = call_user_func_array(array($control_handler, $control['method']), isset($control['params']) ? $control['params'] : array());
                 if (is_array($option_array) && count($option_array) > 0) {
                     // Adding the options array to the select element
                     $this->addOptionArray($option_array);
                 }
             }
         }
     }
 }
Example #21
0
 /**
  * Constructor
  * @param	object    $object   reference to targetobject (@link IcmsPersistableObject)
  * @param	string    $key      the form name
  */
 function __construct($object, $key)
 {
     $var = $object->vars[$key];
     $size = isset($var['size']) ? $var['size'] : ($this->multiple ? 5 : 1);
     // Adding the options inside this SelectBox
     // If the custom method is not from a module, than it's from the core
     $control = $object->getVarControl($key);
     $value = isset($control['value']) ? $control['value'] : $object->getVar($key, 'e');
     parent::__construct($var['title'], $key, $value, $size, $this->multiple);
     if (isset($control['options'])) {
         $this->addOptionArray($control['options']);
     } else {
         // let's find if the method we need to call comes from an already defined object
         if (isset($control['object'])) {
             if (method_exists($control['object'], $control['method'])) {
                 if ($option_array = $control['object']->{$control}['method']()) {
                     // Adding the options array to the XoopsFormSelect
                     $this->addOptionArray($option_array);
                 }
             }
         } else {
             // finding the itemHandler; if none, let's take the itemHandler of the $object
             if (isset($control['itemHandler'])) {
                 if (!$control['module']) {
                     // Creating the specified core object handler
                     $control_handler =& xoops_gethandler($control['itemHandler']);
                 } else {
                     $control_handler =& xoops_getmodulehandler($control['itemHandler'], $control['module']);
                 }
             } else {
                 $control_handler =& $object->handler;
             }
             // Checking if the specified method exists
             if (method_exists($control_handler, $control['method'])) {
                 // TODO : How could I pass the parameters in the following call ...
                 if ($option_array = $control_handler->{$control}['method']()) {
                     // Adding the options array to the XoopsFormSelect
                     $this->addOptionArray($option_array);
                 }
             }
         }
     }
 }
Example #22
0
 /**
  * Constructor
  * @param	object    $object   reference to targetobject (@link icms_ipf_Object)
  * @param	string    $key      the form name
  */
 public function __construct($object, $key)
 {
     $control = $object->getControl($key);
     if (isset($control['delimeter'])) {
         $this->_delimeter = $control['delimeter'];
     }
     parent::__construct($object->vars[$key]['form_caption'], $key, $object->getVar($key), $this->_delimeter);
     if (isset($control['options'])) {
         $this->addOptionArray($control['options']);
     } else {
         // let's find if the method we need to call comes from an already defined object
         if (isset($control['object'])) {
             if (method_exists($control['object'], $control['method'])) {
                 if ($option_array = $control['object']->{$control}['method']()) {
                     // Adding the options array to the select element
                     $this->addOptionArray($option_array);
                 }
             }
         } else {
             // finding the itemHandler; if none, let's take the itemHandler of the $object
             if (isset($control['itemHandler'])) {
                 if (!isset($control['module'])) {
                     // Creating the specified core object handler
                     $control_handler = icms::handler($control['itemHandler']);
                 } else {
                     $control_handler =& icms_getModuleHandler($control['itemHandler'], $control['module']);
                 }
             } else {
                 $control_handler =& $object->handler;
             }
             // Checking if the specified method exists
             if (method_exists($control_handler, $control['method'])) {
                 $option_array = call_user_func_array(array($control_handler, $control['method']), isset($control['params']) ? $control['params'] : array());
                 if (is_array($option_array) && count($option_array) > 0) {
                     // Adding the options array to the select element
                     $this->addOptionArray($option_array);
                 }
             }
         }
     }
 }
Example #23
0
 /**
  * Constructor
  * @param	object    $object   reference to targetobject (@link icms_ipf_Object)
  * @param	string    $key      the form name
  */
 public function __construct($object, $key)
 {
     $category_title_field = $object->handler->identifierName;
     $addNoParent = isset($object->controls[$key]['addNoParent']) ? $object->controls[$key]['addNoParent'] : true;
     $criteria = new icms_db_criteria_Compo();
     $criteria->setSort("weight, " . $category_title_field);
     $category_handler = icms_getModuleHandler('category', $object->handler->_moduleName);
     $categories = $category_handler->getObjects($criteria);
     $mytree = new icms_ipf_Tree($categories, "category_id", "category_pid");
     parent::__construct($object->vars[$key]['form_caption'], $key, $object->getVar($key, 'e'));
     $ret = array();
     $options = $this->getOptionArray($mytree, $category_title_field, 0, $ret, "");
     if ($addNoParent) {
         $newOptions = array('0' => '----');
         foreach ($options as $k => $v) {
             $newOptions[$k] = $v;
         }
         $options = $newOptions;
     }
     $this->addOptionArray($options);
 }
Example #24
0
 /**
  * Constructor
  * @param	object    $object   reference to targetobject (@link IcmsPersistableObject)
  * @param	string    $key      the form name
  */
 function __construct($object, $key)
 {
     $var = $object->vars[$key];
     $size = isset($var['size']) ? $var['size'] : ($this->multiple ? 5 : 1);
     parent::__construct($var['title'], $key, $object->getVar($key, 'e'), $size, $this->multiple);
     // Adding the options inside this SelectBox
     // If the custom method is not from a module, than it's from the core
     $control = $object->getControl($key);
     global $xoopsDB;
     $ret = array();
     $limit = $start = 0;
     $sql = 'SELECT uid, uname FROM ' . $xoopsDB->prefix('users');
     $sql .= ' ORDER BY uname ASC';
     $result = $xoopsDB->query($sql);
     if ($result) {
         while ($myrow = $xoopsDB->fetchArray($result)) {
             $uArray[$myrow['uid']] = $myrow['uname'];
         }
     }
     $this->addOptionArray($uArray);
 }
Example #25
0
 /**
  * Constructor
  * @param	object    $object   reference to targetobject (@link IcmsPersistableObject)
  * @param	string    $key      the form name
  */
 function __construct($object, $var)
 {
     $category_title_field = $object->handler->identifierName;
     $control = $object->getVarControl($var);
     $addNoParent = isset($control['addNoParent']) ? $control['addNoParent'] : true;
     $criteria = new Xmf_Criteria_Compo();
     $criteria->setSort("weight, " . $category_title_field);
     $category_handler = xoops_getmodulehandler('category', $object->handler->_moduleName);
     $categories = $category_handler->getObjects($criteria);
     $mytree = new Xmf_Object_Tree($categories, "category_id", "category_pid");
     parent::__construct($object->getVarKey($var, 'title'), $var, $object->getVar($var, 'e'));
     $ret = array();
     $options = $this->getOptionArray($mytree, $category_title_field, 0, "", $ret);
     if ($addNoParent) {
         $newOptions = array('0' => '----');
         foreach ($options as $k => $v) {
             $newOptions[$k] = $v;
         }
         $options = $newOptions;
     }
     $this->addOptionArray($options);
 }
 /**
  * Perform a search and return JSON encoded results for use in autocompleter
  *
  * @since version 1.0.0
  *
  * @param object $gridField
  * @param object $request
  *
  * @return void
  **/
 public function doSearch($gridField, $request)
 {
     $dataClass = $gridField->getList()->dataClass();
     $allList = $this->searchList ? $this->searchList : DataList::create($dataClass);
     $searchFields = $this->getSearchFields() ? $this->getSearchFields() : $this->scaffoldSearchFields($dataClass);
     if (!$searchFields) {
         throw new LogicException(sprintf('GridFieldAddExistingAutocompleter: No searchable fields could be found for class "%s"', $dataClass));
     }
     $params = [];
     foreach ($searchFields as $searchField) {
         $name = strpos($searchField, ':') !== FALSE ? $searchField : "{$searchField}:StartsWith";
         $params[$name] = $request->getVar('gridfield_relationsearch');
     }
     $results = File::get()->filterAny($params)->filter('ClassName', 'Image')->sort(strtok($searchFields[0], ':'), 'ASC')->limit($this->getResultsLimit());
     $json = [];
     $originalSourceFileComments = Config::inst()->get('SSViewer', 'source_file_comments');
     Config::inst()->update('SSViewer', 'source_file_comments', false);
     foreach ($results as $result) {
         $json[$result->ID] = html_entity_decode(SSViewer::fromString($this->resultsFormat)->process($result));
     }
     Config::inst()->update('SSViewer', 'source_file_comments', $originalSourceFileComments);
     return Convert::array2json($json);
 }
/**
 * xoonips uninstall function
 *
 * @param object $xoopsMod module instance
 * @return bool false if failure
 */
function xoops_module_uninstall_xoonips($xoopsMod)
{
    $mydirname = basename(__DIR__);
    $uid = $GLOBALS['xoopsUser']->getVar('uid', 'n');
    $mid = $xoopsMod->getVar('mid', 'n');
    // get xoops administration handler
    $admin_xoops_handler =& xoonips_gethandler('xoonips', 'admin_xoops');
    // show original 'user' and 'login' blocks
    $sys_blocks = array('user' => array(), 'login' => array());
    if (defined('XOOPS_CUBE_LEGACY')) {
        // for XOOPS Cube Legacy 2.1
        $sys_blocks['user'][] = array('legacy', 'b_legacy_usermenu_show');
        $sys_blocks['login'][] = array('user', 'b_user_login_show');
    }
    $sys_blocks['user'][] = array('system', 'b_system_user_show');
    $sys_blocks['login'][] = array('system', 'b_system_login_show');
    foreach ($sys_blocks as $type => $sys_type_blocks) {
        foreach ($sys_type_blocks as $sys_block) {
            list($dirname, $show_func) = $sys_block;
            $sysmid = $admin_xoops_handler->getModuleId($dirname);
            if ($sysmid === false) {
                continue;
                // module not found
            }
            $bids = $admin_xoops_handler->getBlockIds($sysmid, $show_func);
            foreach ($bids as $bid) {
                $admin_xoops_handler->setBlockPosition($bid, true, 0, 0);
            }
            if (count($bids) != 0) {
                break;
                // found this type's block
            }
        }
    }
    return true;
}
Example #28
0
/**
* Check a user's uname, email, password and password verification
*
* @param object $user {@link XoopsUser} to check
*
* @return string
*/
function userCheck(&$user)
{
    global $xoopsModuleConfig;
    $is_admin = is_object($GLOBALS["xoopsUser"]) && $GLOBALS["xoopsUser"]->isAdmin();
    $is_admin_user = $is_admin && $user->getVar("uid") == $GLOBALS["xoopsUser"]->getVar("uid");
    $stop = '';
    if (!checkEmail($user->getVar('email'))) {
        $stop .= _PROFILE_MA_INVALIDMAIL . '<br />' . print_r($user->getVar('email'));
    }
    if (!$is_admin) {
        foreach ($xoopsModuleConfig['bad_emails'] as $be) {
            if (!empty($be) && preg_match("/" . $be . "/i", $user->getVar('email'))) {
                $stop .= _PROFILE_MA_INVALIDMAIL . '<br />' . print_r($user->getVar('email'));
                break;
            }
        }
    }
    if (strrpos($user->getVar('email'), ' ') > 0) {
        $stop .= _PROFILE_MA_EMAILNOSPACES . '<br />';
    }
    switch ($xoopsModuleConfig['uname_test_level']) {
        case 0:
            // strict
            $restriction = '/[^a-zA-Z0-9\\_\\-]/';
            break;
        case 1:
            // medium
            $restriction = '/[^a-zA-Z0-9\\_\\-\\<\\>\\,\\.\\$\\%\\#\\@\\!\\\'\\"]/';
            break;
        case 2:
            // loose
            $restriction = '/[\\000-\\040]/';
            break;
    }
    if ($user->getVar('loginname') == "" || preg_match($restriction, $user->getVar('loginname')) && !$is_admin_user) {
        $stop .= _PROFILE_MA_INVALIDNICKNAME . "<br />";
    }
    //    if ($user->getVar('name') == "" || preg_match($restriction, $user->getVar('name'))) {
    //        $stop .= _PROFILE_MA_INVALIDDISPLAYNAME."<br />";
    //    }
    if (!$is_admin_user) {
        if (strlen($user->getVar('loginname')) > $xoopsModuleConfig['max_uname']) {
            $stop .= sprintf(_PROFILE_MA_NICKNAMETOOLONG, $xoopsModuleConfig['max_uname']) . "<br />";
        }
        if (strlen($user->getVar('uname')) > $xoopsModuleConfig['max_uname']) {
            $stop .= sprintf(_PROFILE_MA_DISPLAYNAMETOOLONG, $xoopsModuleConfig['max_uname']) . "<br />";
        }
        if (strlen($user->getVar('loginname')) < $xoopsModuleConfig['min_uname']) {
            $stop .= sprintf(_PROFILE_MA_NICKNAMETOOSHORT, $xoopsModuleConfig['min_uname']) . "<br />";
        }
        if (strlen($user->getVar('uname')) < $xoopsModuleConfig['min_uname']) {
            $stop .= sprintf(_PROFILE_MA_DISPLAYNAMETOOSHORT, $xoopsModuleConfig['min_uname']) . "<br />";
        }
    }
    foreach ($xoopsModuleConfig['bad_unames'] as $bu) {
        if (empty($bu) || $is_admin_user) {
            continue;
        }
        if (preg_match("/" . $bu . "/i", $user->getVar('loginname'))) {
            $stop .= _PROFILE_MA_NAMERESERVED . "<br />";
            break;
        }
        if (preg_match("/" . $bu . "/i", $user->getVar('uname'))) {
            $stop .= _PROFILE_MA_DISPLAYNAMERESERVED . "<br />";
            break;
        }
    }
    if (strrpos($user->getVar('loginname'), ' ') > 0) {
        $stop .= _PROFILE_MA_NICKNAMENOSPACES . "<br />";
    }
    //    if (strrpos($user->getVar('name'), ' ') > 0) {
    //        $stop .= _PROFILE_MA_DISPLAYNAMENOSPACES."<br />";
    //    }
    $member_handler =& xoops_gethandler('member');
    $count_criteria = new Criteria('loginname', $user->getVar('loginname'));
    $display_criteria = new Criteria('uname', $user->getVar('uname'));
    if ($user->getVar('uid') > 0) {
        //existing user, so let's keep the user's own row out of this
        $count_criteria = new CriteriaCompo($count_criteria);
        $display_criteria = new CriteriaCompo($display_criteria);
        $useridcount_criteria = new Criteria('uid', $user->getVar('uid'), '!=');
        $useriddisplay_criteria = new Criteria('uid', $user->getVar('uid'), '!=');
        $count_criteria->add($useridcount_criteria);
        $display_criteria->add($useriddisplay_criteria);
    }
    $count = $member_handler->getUserCount($count_criteria);
    $display_count = $member_handler->getUserCount($display_criteria);
    unset($count_criteria);
    unset($display_criteria);
    if ($count > 0) {
        $stop .= _PROFILE_MA_NICKNAMETAKEN . "<br />";
    }
    if ($display_count > 0) {
        $stop .= _PROFILE_MA_DISPLAYNAMETAKEN . "<br />";
    }
    $count = 0;
    if ($user->getVar('email')) {
        $count_criteria = new Criteria('email', $user->getVar('email'));
        if ($user->getVar('uid') > 0) {
            //existing user, so let's keep the user's own row out of this
            $count_criteria = new CriteriaCompo($count_criteria);
            $count_criteria->add(new Criteria('uid', $user->getVar('uid'), '!='));
        }
        $count = $member_handler->getUserCount($count_criteria);
        unset($count_criteria);
        if ($count > 0) {
            $stop .= _PROFILE_MA_EMAILTAKEN . "<br />";
        }
    }
    return $stop;
}
Example #29
0
 /**
  * Send a message to user's email
  * @param 	object 	$pm 	{@link XoopsPrivmessage} object
  * @param 	object 	$user
  * @return 	bool
  **/
 function sendEmail(&$pm, &$user)
 {
     global $xoopsConfig;
     if (!is_object($user)) {
         $user =& $GLOBALS["xoopsUser"];
     }
     $msg = sprintf(_PM_EMAIL_DESC, $user->getVar("uname"));
     $msg .= "\n\n";
     $msg .= formatTimestamp($pm->getVar("msg_time"));
     $msg .= "\n";
     $from = new XoopsUser($pm->getVar("from_userid"));
     $to = new XoopsUser($pm->getVar("to_userid"));
     $msg .= sprintf(_PM_EMAIL_FROM, $from->getVar("uname") . " (" . XOOPS_URL . "/userinfo.php?uid=" . $pm->getVar("from_userid") . ")");
     $msg .= "\n";
     $msg .= sprintf(_PM_EMAIL_TO, $to->getVar("uname") . " (" . XOOPS_URL . "/userinfo.php?uid=" . $pm->getVar("to_userid") . ")");
     $msg .= "\n";
     $msg .= _PM_EMAIL_MESSAGE . ":\n";
     $msg .= "\n" . $pm->getVar("subject") . "\n";
     $msg .= "\n" . strip_tags(str_replace("<p>", "\n", str_replace("</p>", "\n", str_replace("<br>", "\n", str_replace("<br />", "\n", $pm->getVar("msg_text")))))) . "\n\n";
     $msg .= "--------------\n";
     $msg .= $xoopsConfig['sitename'] . ": " . XOOPS_URL . "\n";
     $xoopsMailer =& getMailer();
     $xoopsMailer->useMail();
     $xoopsMailer->setToEmails($user->getVar("email"));
     $xoopsMailer->setFromEmail($xoopsConfig['adminmail']);
     $xoopsMailer->setFromName($xoopsConfig['sitename']);
     $xoopsMailer->setSubject(sprintf(_PM_EMAIL_SUBJECT, $pm->getVar("subject")));
     $xoopsMailer->setBody($msg);
     return $xoopsMailer->send();
 }
Example #30
0
 /**
  * activate a user
  * 
  * @param object $user reference to the {@link XoopsUser} object
  * @return bool successful?
  */
 function activateUser(&$user)
 {
     if ($user->getVar('level') == 1) {
         return true;
     }
     $user->setVar('level', 1);
     return $this->_uHandler->insert($user, true);
 }