public function onSubmit(Zend_Controller_Request_Abstract $request) { // Form was valid $skip = $request->getParam("skip"); // do this if the form value for "skip" was not set // if it is set, $this->setActive(false); $this->onsubmisvalue and return true. if ($skip == "skipForm") { $this->setActive(false); $this->onSubmitIsValid(); $this->getSession()->skip = true; $this->_skip = true; return true; } else { parent::onSubmit($request); } }
public function onSubmit(Zend_Controller_Request_Abstract $request) { // Form was valid $skip = $request->getParam("skip"); $uploadPhoto = $request->getParam("uploadPhoto"); $finishForm = $request->getParam("nextStep"); $this->_coordinates = $request->getParam("coordinates"); // do this if the form value for "skip" was not set // if it is set, $this->setActive(false); $this->onsubmisvalue and return true. if ($this->getForm()->isValid($request->getPost()) && $skip != "skipForm" && $uploadPhoto == true && $finishForm != "finish") { $this->getSession()->data = $this->getForm()->getValues(); $this->getSession()->Filedata = $this->getForm()->Filedata->getFileInfo(); $file = APPLICATION_PATH . '/public/temporary/' . $this->getSession()->data['Filedata']; $path = dirname($file); $name = basename($file); $this->_resizeImages($this->getForm()->Filedata->getFileName()); $_SESSION['TemporaryProfileImg'] = $name; $this->getSession()->active = true; $this->onSubmitNotIsValid(); return false; } else { if ($skip != "skipForm" && $finishForm == "finish" && isset($_SESSION['TemporaryProfileImg'])) { $this->setActive(false); $this->onSubmitIsValid(); return true; } else { if ($skip == "skipForm" || !isset($_SESSION['TemporaryProfileImg']) && $finishForm == "finish") { $this->setActive(false); $this->onSubmitIsValid(); $this->getSession()->skip = true; $this->_skip = true; return true; } else { $this->getSession()->active = true; $this->onSubmitNotIsValid(); return false; } } } parent::onSubmit($request); /* $photo_uploaded = !empty($this->getSession()->data['Filedata']); $is_uploading = !empty($_FILES['Filedata']['name']); // Action : reset image if( !empty($values['change']) ) { $this->resetSession(); return false; } // Step 1: Upload if( !$photo_uploaded && $is_uploading ) { /// Icky hack because zend can't have a file within a subform $values = $this->getActionController()->getRequest()->getPost(); // Check valid and store if yes if( $this->getForm()->isValid($values) ) { $data = $this->getForm()->getValues(); $this->getSession()->data = $data; $this->getSession()->photo_url = Zend_Controller_Front::getInstance()->getBaseUrl().'/public/temporary/p_'.$data['Filedata']; $this->getSession()->thumb_url = Zend_Controller_Front::getInstance()->getBaseUrl().'/public/temporary/is_'.$data['Filedata']; $this->_resizeImages($this->getForm()->getFileElement()->getFileName()); return true; } else { return false; } } // Step 2: Accept else if( $photo_uploaded ) { $this->getSession()->active = false; } * */ }
public function onSubmit(Zend_Controller_Request_Abstract $request) { if ($request->getParam("skip") == "skipForm") { $this->setActive(false); $this->onSubmitIsValid(); $this->getSession()->skip = true; $this->_skip = true; return true; } //get default level_id $table = Engine_Api::_()->getDbtable('levels', 'authorization'); $defaultLevelDuplicates = $table->select()->from($table)->where('flag = ?', 'default')->query()->fetchAll(); $default_level = @$defaultLevelDuplicates[0]['level_id']; $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer'); if (null !== $viewRenderer && $viewRenderer->view instanceof Zend_View_Interface) { $this->view = $viewRenderer->view; } $settings = Engine_Api::_()->getApi('settings', 'core'); $this->view->step = ''; $task = $request->getPost('task', ''); $is_error = 0; if ($request->isPost()) { $values = $request->getPost(); $this->view->login = $post_login = $request->getPost('user'); if ($task == 'manual_invite') { $this->getSession()->manual_invite = $values; $this->onSubmitIsValid(); parent::onSubmit($request); return true; } elseif ($task == 'get_contacts' || isset($_POST['get_success'])) { $this->view->max_invitation = $max_invitation = Engine_Api::_()->authorization()->getPermission($default_level, 'contactimporter', 'max'); /******Get contact from openId*****/ $cur_url = $_SERVER['REQUEST_URI']; parse_str($cur_url, $params); $contacts = array(); $index = 0; $id = ""; $name = ""; $pic = ""; $getcontact = false; $token = ""; $secret_token = ""; $provider = ""; $is_openid = false; $page = 1; $checked = 0; foreach ($params as $key => $val) { if (strpos($key, '?user') !== false) { $provider = 'twitter'; $_SESSION['socialbridge_session']['provider'] = $provider; $_SESSION['socialbridge_session'][$provider]['user_id'] = $val; $is_openid = true; } if (strpos($key, 'oauth_tok3n') !== false) { $token = $val; $_SESSION['socialbridge_session'][$provider]['access_token'] = $token; $is_openid = true; } if (strpos($key, 'oauth_token_secret') !== false) { $secret_token = $val; $_SESSION['socialbridge_session'][$provider]['secret_token'] = $secret_token; $is_openid = true; } $pic = null; if (strpos($key, 'id_') !== false) { $id = $val; } if (strpos($key, 'name_') !== false) { $name = $val; } if (strpos($key, 'pic_') !== false) { $pic = $val; $index = 2; } if ($index >= 2) { $contacts[$id] = array('id' => $id, 'name' => $name, 'pic' => $pic); } } $totalFriends = $totalFriendSearch = $checked = 0; if ($provider == 'twitter') { $obj = Engine_Api::_()->socialbridge()->getInstance('twitter'); $params = $_SESSION['socialbridge_session']['twitter']; $contacts = $obj->getContacts($params); } if ($provider) { $getcontact = true; if ($_REQUEST['page_id']) { $page = $_REQUEST['page_id']; } if (!isset($_SESSION['ynfriends_checked'])) { $_SESSION['ynfriends_checked']['page_friendIds'] = ''; $_SESSION['ynfriends_checked']['page_friendNames'] = ''; } // check total checked $arr_Friends = explode(',', $_SESSION['ynfriends_checked']['page_friendIds']); if (isset($_REQUEST['page_friendIds']) && $_REQUEST['page_friendIds']) { $arr_FriendNames = explode(',', $_REQUEST['page_friendNames']); foreach (explode(',', $_REQUEST['page_friendIds']) as $key => $value) { if ($value && !in_array($value, $arr_Friends)) { $_SESSION['ynfriends_checked']['page_friendIds'] .= $value . ","; $_SESSION['ynfriends_checked']['page_friendNames'] .= $arr_FriendNames[$key] . ','; } } } $checked = count(explode(',', $_SESSION['ynfriends_checked']['page_friendIds'])); if ($checked) { $checked = $checked - 1; } $this->view->friendIds = $_SESSION['ynfriends_checked']['page_friendIds']; $this->view->friendNames = $_SESSION['ynfriends_checked']['page_friendNames']; $this->view->page = $page; $this->view->checked = $checked; $this->view->provider = $provider; $this->view->step = 'invite'; $this->view->plugType = "social"; $this->view->contacts = $contacts; $this->view->totalFriends = $totalFriends; $this->view->totalFriendSearch = $totalFriendSearch; $settings = Engine_Api::_()->getApi('settings', 'core'); $this->view->default_message = $settings->getSetting('invite.message'); $this->view->show_photo = 1; return; } //Yahoo and Gmail if (isset($_POST) && isset($_POST['contact'])) { $contacts = array(); $aYahooContacts = $_POST['contact']; $aYahooContacts = urldecode($aYahooContacts); $aYahooContacts = Zend_Json::decode($aYahooContacts); if (!$aYahooContacts || count($aYahooContacts) <= 0) { return $contacts; } foreach ($aYahooContacts as $key => $aContact) { $contacts[$aContact['email']] = $aContact['name']; } // Divide to 2 type: already register recipients & non-registered recipients $social_network = array(); $invite_list = array(); $invite_list_to_st = ""; foreach ($contacts as $email => $name) { if (Engine_Api::_()->contactimporter()->getUser($email)) { $user = Engine_Api::_()->contactimporter()->getUser($email); $social_network[$email] = array('name' => $user->getTitle(), 'pic' => $user->getPhotoUrl('thumb.icon')); } elseif (!in_array($email, $ignore_list)) { $invite_list[$email] = $name; if (is_array($name)) { $invite_list_to_st .= ";{$email}~~~~{$name['name']}"; } else { $invite_list_to_st .= ";{$email}~~~~{$name}"; } } } if ($social_network) { $this->view->contacts = $social_network; $this->view->invite_list = substr($invite_list_to_st, 1); $this->view->step = 'add'; $this->view->page = 1; $this->view->checked = 0; } else { $is_openid = false; $this->view->contacts = $contacts; $this->view->step = 'invite'; $settings = Engine_Api::_()->getApi('settings', 'core'); $this->view->default_message = $settings->getSetting('invite.message'); $this->view->show_photo = 0; $this->view->plugType = "email"; $this->view->page = 1; $this->view->checked = 0; } $getcontact = true; return; } $table = Engine_Api::_()->getDbtable('providers', 'Contactimporter'); $select = $table->select(); $select->where('enable = ?', 1)->order('order', 'ASC'); $oi_services = $table->fetchAll($select); $this->view->step = 'get_contacts'; $this->view->providers = $providers = $table->fetchAll($select); unset($_SESSION['ynfriends_checked']); } //ADD CONTACT LIST if ($task == 'do_add') { $this->view->max_invitation = $max_invitation = Engine_Api::_()->authorization()->getPermission($default_level, 'contactimporter', 'max'); $this->view->plugType = $values['plugType']; $this->view->oi_session_id = $values['oi_session_id']; $this->view->provider = $values['provider']; $selected_contacts = array(); $aFriendIdSelected = explode(',', $values['friendIds']); $aFriendNameSelected = explode(',', $values['friendNames']); foreach ($aFriendIdSelected as $key => $val) { if ($val) { $selected_contacts[$val] = $aFriendNameSelected[$key]; } } $this->getSession()->Contactimporter_add = $selected_contacts; if (isset($values['invite_list']) && $values['invite_list']) { $contacts = array(); $contacts_invite = explode(';', $values['invite_list']); foreach ($contacts_invite as $contact) { $tmp = explode("~~~~", $contact); if (isset($tmp[1])) { $contacts[$tmp[0]] = $tmp[1]; } } $this->view->contacts = $contacts; $this->view->page = 1; $this->view->checked = 0; if ($contacts) { $this->view->step = 'invite'; } } else { // FINISHED $this->onSubmitIsValid(); parent::onSubmit($request); return true; } unset($_SESSION['ynfriends_checked']); } if ($task == 'do_invite') { $plugType = $values['plugType']; $oi_session_id = $values['oi_session_id']; $this->view->max_invitation = $max_invitation = Engine_Api::_()->authorization()->getPermission($default_level, 'contactimporter', 'max'); $selected_contacts = array(); $aFriendIdSelected = explode(',', $values['friendIds']); $aFriendNameSelected = explode(',', $values['friendNames']); foreach ($aFriendIdSelected as $key => $val) { if ($val) { $selected_contacts[$val] = $aFriendNameSelected[$key]; } } $this->getSession()->Contactimporter_invite = array("contacts" => $selected_contacts, 'plugin_type' => $plugType, 'provider' => $values['provider'], 'message' => $values['message'], 'oi_session_id' => $oi_session_id); // FINISHED unset($_SESSION['ynfriends_checked']); $this->onSubmitIsValid(); parent::onSubmit($request); return true; } if ($task == 'skip_add') { if (isset($values['invite_list']) && $values['invite_list']) { $contacts = array(); $contacts_invite = explode(';', $values['invite_list']); foreach ($contacts_invite as $contact) { $tmp = explode("~~~~", $contact); if (isset($tmp[1])) { $contacts[$tmp[0]] = $tmp[1]; } } $this->view->contacts = $contacts; $this->view->step = 'invite'; $this->view->max_invitation = $max_invitation = Engine_Api::_()->authorization()->getPermission($default_level, 'contactimporter', 'max'); $this->view->plugType = $values['plugType']; $this->view->oi_session_id = $values['oi_session_id']; $this->view->provider = $values['provider']; $this->view->page = 1; $this->view->checked = 0; } else { $this->setActive(false); $this->onSubmitIsValid(); $this->getSession()->skip = true; $this->_skip = true; return true; } unset($_SESSION['ynfriends_checked']); } if ($task == 'skip_invite') { unset($_SESSION['ynfriends_checked']); // FINISHED $this->onSubmitIsValid(); parent::onSubmit($request); return true; } } $this->getSession()->active = true; $this->onSubmitNotIsValid(); return false; }
public function isActive() { return parent::isActive(); }
public function onSubmit(Zend_Controller_Request_Abstract $request) { return parent::onSubmit($request); }
public function onSubmit(Zend_Controller_Request_Abstract $request) { // Form was valid $skip = $request->getParam("skip"); $photoIsRequired = $request->getParam("skip"); $uploadPhoto = $request->getParam("uploadPhoto"); $finishForm = $request->getParam("nextStep"); $this->getSession()->coordinates = $request->getParam("coordinates"); // do this if the form value for "skip" was not set // if it is set, $this->setActive(false); $this->onsubmisvalue and return true. if ($this->getForm()->isValid($request->getPost()) && $skip != "skipForm" && $uploadPhoto == true && $finishForm != "finish") { $this->getSession()->data = $this->getForm()->getValues(); $this->getSession()->Filedata = $this->getForm()->Filedata->getFileInfo(); $this->_resizeImages($this->getForm()->Filedata->getFileName()); $this->getSession()->active = true; $this->onSubmitNotIsValid(); return false; } else { if ($skip != "skipForm" && $finishForm == "finish" && isset($_SESSION['TemporaryProfileImg'])) { $this->setActive(false); $this->onSubmitIsValid(); return true; } else { if ($photoIsRequired && ($skip == "skipForm" || !isset($_SESSION['TemporaryProfileImg']) && $finishForm == "finish")) { $this->setActive(false); $this->onSubmitIsValid(); $this->getSession()->skip = true; $this->_skip = true; return true; } else { $this->getSession()->active = true; $this->onSubmitNotIsValid(); return false; } } } parent::onSubmit($request); }